CLion 2020.1 EAP: Macros and Variables in Configurations, Input Redirection, and More
A new CLion 2020.1 EAP build is now available for download!
You can download the build (201.6487.17) from our website, via the Toolbox App, or as a snap package (for Ubuntu), and you can install it side by side with the stable release build.
- Support for macros and path variables in Run/Debug configurations.
- Input redirection.
- Clangd-only completion.
- Other improvements.
Support for macros and path variables in Run/Debug configurations
Sometimes, instead of running your program directly, you may want to pass it as an argument to another program started from CLion (when using an emulator, for example). Or you might want to use a project-related path in the Program Arguments or Working Directory fields in the Run/Debug Configurations. Now you can do that!
Macros and path variables can currently be used in the following configuration types:
- CMake Application
- Custom Build Application
- Gradle Native Application
Further work is still required for unit testing, the Remote GDB Server, and some other configuration types.
Editor macros give you access to values like:
- The build directory for the current CMake run configuration.
- The generation directory for the current CMake run configuration.
- The project file directory.
- And many others.
Alternatively, you can use Path Variables, which you can configure in Settings/Preferences | Appearance & Behavior | Path Variables. The typical use case is creating a Path Variable for a library that is used widely in your projects but is located outside the project directory (check our webhelp article to learn how to configure it).
Path variables and editor macros can be used in the Program Arguments or Working Directory fields in the Run/Debug Configurations. For macros, click the plus sign to open the full list:
Sometimes you want to redirect input from a file to stdin of your application. This is now possible! In the Run/Debug Configuration, you’ll find a new field called Redirect input from. Enable it, and fill in the file path/name:
A few things worth mentioning here:
- The macros and path variables mentioned above work here as well.
- Relative paths are prepended with the Working directory path.
- Absolute paths, in the case of remote configurations, will be mapped to the remote paths according to the path mappings configured in the Deployment settings.
Tip: If you want CLion to ask you to choose a file input every time you run the application, use the FilePrompt macro here, which invokes a file selection dialog on every application launch:
A few known issues:
- Input redirection does not yet work when debugging with GDB using the Cygwin toolchain.
- Input redirection currently works only with the CMake Application, Custom Build Application, and Gradle Native Application Run/Debug configurations.
In 2019.3, we introduced Clangd-based code completion in CLion. Clangd, as one of the completion providers, helps deliver faster completion results. However, the rules for mixing Clangd with CLion’s own completion provider are quite complicated. Sometimes they even cause issues with the prioritization and ordering of results. After a few rounds of tests and measurements, we’ve decided to turn on a new mode in which completion is fully provided by Clangd. Of course, if a crash or some other serious issue occurs, CLion will silently switch to other providers to be sure that completion is still operating. CLion also uses its own completion to provide symbols from non-included files if Clangd-based completion fails to find anything.
This behavior is controlled by the Code Completion setting in Settings/Preferences | Languages & Frameworks | C/C++ | Clangd. At the moment, Only Clangd completion is set as the default value.
Additionally, to make Clang-based code completion (and thus CLion completion) more stable and accurate, this build comes with the following improvements:
- Fixes to several Clangd crashes.
- Completion for
using namespaceshould suggest only namespaces (CPP-19175) and a space should be inserted (CPP-11766).
- Frameworks are no longer duplicated in the completion list (CPP-19127).
- Completion now suggests keywords
- Completion now inserts angle brackets for template functions and classes that require it (like for example,
std::make_unique, and others):
Data Flow Analysis (DFA) was recently moved to Clangd, and now we’ve given it a few fixes and improvements, including:
- More accurate Local variable not used inspection on structured bindings (CPP-12900, CPP-13006).
- Fixes for the incorrect Unreachable code errors (CPP-19185).
- CMake 3.16.5 is now bundled.
- Fixes for CMake not working in many cases when user paths contain non-ascii characters.
And there are, of course, many others. You can find the full release notes here.
Your CLion team
The Drive to Develop