Clion logo

The CLion Blog

A Cross-Platform IDE for C and C++

Early Access Program

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

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.

Edit Macros

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:
Prompt arguments

Input redirection

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:

Input redirection

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:
Prompt redirection

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.

Clangd-only completion

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 namespace should 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 class and struct for enum (CPP-18957).
  • Completion now inserts angle brackets for template functions and classes that require it (like for example, std::numeric_limits, boost::lexical_cast, std::make_shared, std::make_unique, and others):
    Completion for angle brackets

Other improvements

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).

For toolchains:

  • 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

Comments below can no longer be edited.

33 Responses to CLion 2020.1 EAP: Macros and Variables in Configurations, Input Redirection, and More

  1. Mark says:

    March 19, 2020

    Can you make an update on thin-client feature (which is kind of hot-topic with on-going shift to remote work). By thin-client i mean using one ide instance as an ui front-end for other ide instance running as back-end (running on remote pc). Is such feature still considered to be implemented, what is the priority and eta?

    • Anastasia Kazakova says:

      March 19, 2020

      Yes, this is the general direction we are very much interested in JetBrains. We are conducting some researches in this direction. But can’t provide you with any estimations at this point. Meanwhile, you can rely on the currently available options for the remote development in CLion:

    • Roman Popov says:

      March 19, 2020

      I’m using Clion in VNC. Works fine for me. Not sure what is the value of Clion-only thin client, since you usually need to use many other GUI tools, not only C++ IDE.

    • fenrir says:

      March 20, 2020

      I sometimes use CLion with good old X forwarding. It works surprisingly well like that.

      • Mark says:

        March 20, 2020

        Yes, this is the best option we have currently, but it requires the remote to have X installed, which somtimes is not feasible.

        • xiamiaoren says:

          March 21, 2020

          The most important demand is to offload computation. For large C++ project, Clion needs over 20GB memory, which is huge hardware reqirement for laptop.
          The VNC and X forwarding are not feasible in WAN. There are large latency and bandwidth limitation for giving favorable user experience.
          One example has implemented the feature you suggested is VSCode, which whill install server side component and offload most part of work to server.

  2. Remote User says:

    March 19, 2020

    Are you planning on adding macros for remote paths? (Useful in remote deployment scenarios.)

    In CLion’s remote deployment, the project’s files (source and binaries) are kept in a directory with some random auto-generated name (e.g. “/tmp/randomstring”).
    Then, when creating external tools, you have to explicitly write out that directory’s name in order to reference your remote files (for example, the most common use case is probably interacting with your built object files using an external tool).

    Thank you!

    • Anastasia Kazakova says:

      March 19, 2020

      Thanks for the idea. You can actually change this /tmp path in the Deployment settings.

      • Remote User says:

        March 19, 2020

        Thank you Anastasia for your comment!
        The /tmp path is a great feature – the only thing that’s missing is the ability to reference that path (or whichever remote path was chosen).

        This will allow different employees which use remote deployment on the same server (as is the case in our company) to use the same configuration. (Right now the situation is that each employee must enter his remote path manually, as there is no macro for it.)

  3. Yaroslav says:

    March 19, 2020

    > Support for macros and path variables

    • Anastasia Kazakova says:

      March 19, 2020

      Glad you liked it)

  4. HGH says:

    March 20, 2020

    Are these improvements coming to Android Studio too?

    • Anastasia Kazakova says:

      March 20, 2020

      That depends on Google, we are unaware of their plan, but they might get it if they decide AS needs it

  5. Espen Frimann Koren says:

    March 20, 2020

    Hi. I have a wish regarding support for git submodules. In a git repository that refers to a git submodule, when I checkout a different branch inside the submodule, the parent repository reports that the submodule has changes (using git on the command line), but CLion don’t seem to detect this.

    An example; if I make a feature branch in the parent repository and in the submodule and do my changes, both in the parent repository and in the submodule and use CLion to commit and push my changes, everything of course works fine locally. But the CI server will NOT build, since the fact that the submodule in my local parent repository has changed is NOT commited and pushed by CLion. I have to open a terminal an write “git commit -am “….” && git push to update the parent and push it so that the CI will get the change.

    I have read all I can find about this, but I cannot figure it out. If it is not a bug from your side, but implemented like this for a reason, I would very much like to know the reason.

  6. Roel Van Zeebroeck says:

    March 20, 2020

    Hi, in the MacOS version, the “preview diff” button in the commit dialog is gone. I use it a lot…

    Is this intentional? Can I bring it back?

    • Dmitriy Smirnov says:

      March 20, 2020

      Diff Preview opens in Editor on double-click on a changed file.

    • Anastasia Kazakova says:

      March 20, 2020

      Could you please show a screenshot?

      • Roel Van Zeebroeck says:

        March 23, 2020

        Here’s two screenshots:
        The first one shows how it used to be. The second one shows a screenshot where the button is missing.

        I know I can open a diff Window in the Editor by double clicking on a file. For me, the old behaviour was better for two reasons:
        1) I did not have to double click. I could just click on a file and would see the diff instantly to the right. I could even switch between files using the arrow keys and would not have to hit enter to see the diff. Very handy.
        2) I actually liked the diff preview to the right of the commit dialog, especially for small diffs. Only for more complicated diffs I would double click, which would open in a separate Window (not in the Editor).

        • Anastasia Kazakova says:

          March 23, 2020

          I see now, thanks.

          Let me first note that you have now to double click once. After that you can, as before, switch between files with the arrow keys and the diff will be switched as well automatically.

          But I’ll anyway pass this feedback to our VCS team so that they can address it.

          • Roel Van Zeebroeck says:

            March 23, 2020

            Ok, thanks for the tip. I didn’t know I can still use the arrow keys. It helps, though I still like the old behaviour better.

        • Dmitriy Smirnov says:

          March 23, 2020

          The diff that opens in editor is the same diff preview it used to be but in the new location. The icon on the toolbar has been changed to the double click. Just close the tab with diff to hide it.
          And you still can open diff in separate frame with Ctrl+D

          >I actually liked the diff preview to the right of the commit dialog

          Commit toolwindow default location is on the left, so the preview is exactly to the right of it.

          > Only for more complicated diffs I would double click, which would open in a separate Window

          As a side note, double click used to open the file in the editor, not its diff.

          If you want to restore Local Changes with preview in it back to the Git toolwindow, you can disable the non-modal UI and keep using commit dialog.

          • Roel Van Zeebroeck says:

            March 24, 2020

            >Commit toolwindow default location is on the left, so the preview is exactly to the right of it.
            It’s always been on the bottom for me (together with TODO, Git, Terminal, …). It looks like this: Not exactly to the right. I think that’s what’s bothering me the most: it’s bottom-left vs top-right. Has the default location changed? Notice it’s in the same location as in IntelliJ and WebStorm.

  7. Jonas Gilg says:

    March 20, 2020

    The macros are very cool. Are you planning to add them to the cmake options configuration too? This would be awesome.

  8. Taw says:

    March 24, 2020

    Anastasia, what clang are you using in CLion? Because it seems that clang-tidy is 11git or smth, but the latest official LLVM is 9.

    ~/.local/share/JetBrains/Toolbox/apps/CLion/ch-1/201.6487.17/bin/clang/linux$ ./clang-tidy –version
    LLVM (
    LLVM version 11.0.0git
    Optimized build.
    Default target: x86_64-unknown-linux-gnu
    Host CPU: skylake

    • Anastasia Kazakova says:

      March 24, 2020

      Current CLion doesn’t use the latest revision. It uses

      • Taw says:

        March 24, 2020

        Ok, but what version is this? Because it’s 2 versions above the official one…

        • Anastasia Kazakova says:

          March 26, 2020

          We are constantly updating Clangd and other Clang-based tools used in CLion. This process is not aligned with the official releases. So you can compare by revision where current CLion version is.

  9. Victor Sergienko says:

    April 4, 2020

    Redirect input, but not output or stderr?..
    That’s a… surprising design decision.

    Speaking of macros, I’ve been long wanting a new macro, SelectedFilePaths (IDEA-97869) for external tools.
    Currently, external tool is unable to process a batch of files.

    • Anastasia Kazakova says:

      April 6, 2020

      Input redirection was a very popular request so far. We have another one for the output:

      I see your comments in IDEA-97869 and hope we’ll be able to get to it soon, but for now there are others with higher priority. But thanks for pinging us, we’ll recheck.

Discover more