CLion 2017.1 released: C++14, C++17, PCH, disassembly view, Catch, MSVC and more

Please give a warm welcome to CLion 2017.1!

CLion_20171_1000x500

Our first big update this year includes:

Download CLion 2017.1

Modern C++ standards

As C++17 has already been approved, we’ve sped up to support the latest C++ standards. The following features of C++14 are recognized in v2017.1:

  • auto return type,
  • generic lambdas,
  • variable templates, and
  • generalized lambda captures.

Support for these language features includes correct highlighting and no false-positives in code analysis, as well as correct code completion, navigation and refactorings. For example, earlier you couldn’t get the code completion in the case below as CLion was not able to correctly infer the type of vec variable:
cpp14_auto_return
Now this works fine in CLion.

This means that only constexpr is actually missing from C++14. As for C++17, we’ve started with the most upvoted feature, nested namespaces.
cpp17_nested_namespaces

There are dozens of fixes for incorrect code resolve and thus no more false code analysis and other related issues. Check out the build to see if CLion got better for you!

Support for C++11 and C++14 will be polished in 2017.1.x and 2017.2 releases, and hopefully we’ll be able to devote more time to C++17.

Make auto

While working on modern C++ standards, developers see how new language features can help make their code more accurate and readable. What if an IDE could assist you with the task of modernizing your code? Sounds good, doesn’t it?

The first step we’ve taken in this direction is to add a ‘convert variable type to auto’ intention in CLion 2017.1. Just put the caret on the type or variable name, and invoke the available intentions list with Alt+Enter:
Make auto intention

Be careful – keep the code modern, but self-documented. The best general cases to convert variable type to auto are iterators, type casts and new-expressions.

Precompiled headers and more

Precompiled headers and the -include compiler option is a way to reduce compilation time and keep large-scale codebases structured and clear. When using this, you simply compile expensive includes once and then guide the compiler to reuse that information.

CLion 2017.1 correctly resolves symbols from such headers, suggests code completion, navigate to the declarations and definitions.
PCH

Check more details.

Debugger

The debugger in CLion 2017.1 received several important bug fixes and a workaround for the GDB timeout issue (which unfortunately still happens to some CLion users).

However, the most important and long-awaited change is the disassembly view in the debugger. When the sources are unavailable, you still can step into and view the disassembly code. Step through it to investigate the issue in your program deeper or to understand what’s happening inside a library call.
Disassembly view

For now this only works for GDB. For more about the limitations and known issues, see this.

Besides, if you just open a .s or .asm file in CLion (or other extensions, if you add them to Settings | Editor | File Types | Assembly Language) which uses the AT&T dialect and no preprocessor, it will be appropriately highlighted in the editor.

Catch

There are lots of unit test frameworks for C++: Google Test, Boost, CppUnit, CppTest and many more. Catch is one that’s known for its easy starting process (just include a simple header) and convenient and flexible test cases.

CLion has had Google Test support for a while, and now we’ve introduced Catch support. It includes a built-in test runner that allows you to view the test results and sort them by duration, rerun failed tests, export test results, navigate instantly to the source code, etc.

Catch

The special Catch Run/Debug configuration is flexible enough to run any preferred set of tests within CLion. For your convenience, it provides you with completion of Catch tags and wildcard-based matching templates to speed up configuration.

catch_completion

To learn more about Catch and how it’s supported in CLion, read this detailed blog post.

Microsoft Visual C++ compiler

One more feature that many of our users have requested is support for Microsoft Visual C++ compiler.

There are three important things you need to know if you’d like to try it in CLion:

  1. Use the Registry option clion.enable.msvc to enable this support (in Find Action dialog (Shift+Ctrl+A on Linux/Windows, ⇧⌘A on macOS) type Registry; open Registry, type clion.enable.msvc to search for the settings and turn it on).
  2. CLion supports Microsoft Visual C++ compiler that ships with Visual Studio 2013, 2015 and 2017.
  3. There’s no support for msbuild. CLion works through CMake with the NMake generator. Besides, debugger is not yet supported.

msvc_release1

CLion auto-detects the Visual Studio versions installed on your machine; provides settings to configure the Microsoft Visual C++ compiler path, architecture and platform; and finally runs Microsoft Visual C++ compiler to compile your program. It also helps with navigation through the compiler errors in the Messages Build tool window.

It’s important to understand that this support is currently experimental, meaning there are known issues, the biggest being that there’s no support yet for specific Microsoft C++ language extensions. We will continue to work on it within the 2017.2 EAP.

Find in Path

In CLion it’s possible to search for text across the whole project or any selected scope, with the Find in Path dialog (Shift+Ctrl+F on Linux/Windows, ⇧⌘F on macOS). Now it has a popup window with immediate preview, though you can still open a separate Find Window if you wish:
Catch

VCS: enhanced log view and branches popup

CLion 2017.1 enhances its Log View, making search easier with regular expressions and the ability to match/ignore case.
match case in log viwer

If you have lots of branches in your project and are afraid of getting lost in them, mark the most important ones as Favorites. The redesigned branches popup then allows you to filter them and view only the favorites.

Swift and other plugins

If you are looking for a Swift IDE on Linux, check the Swift plugin for CLion. Thanks to the AppCode team, it now comes with important enhancements that make development in Swift easier:

  • Create new project wizard provides ability to create Swift projects
  • SourceKit-based inspections and intentions are available in the plugin
  • Generate type and initializers from usage

Swift

Besides, Go plugin was updated and now correlates with Gogland functionality.

That’s it! Explore all the new features in more detail on our website and watch this overview video:

To play with the new features, check our special repository that we maintain in order to illustrate changes in CLion 2017.1 in a very code-centric way.

Start your 30-day free evaluation and check all the new features and fixes.

Download CLion 2017.1

Your CLion Team

JetBrains
The Drive to Develop

This entry was posted in Announcement and tagged , , , , , , , , . Bookmark the permalink.

51 Responses to CLion 2017.1 released: C++14, C++17, PCH, disassembly view, Catch, MSVC and more

  1. Olof says:

    I think you forgot to bang your drum for the feature that in my opinion is by far the best improvement. The zero latency typing.

    Together with other improvements to responsiveness in 2017.1 and I think some from 2016.3 the improvement has been great. I still lock up for periods of time so things can still get better, but still, bravo.

    Is there an ETA for when the VIM plugin will be released using the zero latency api?

    • Anastasia Kazakova says:

      Thanks Olof!

      I suppose the plugin should be release in a couple of weeks form now.

      • Olof says:

        Thanks.

        I’m running with the beta, 0.48.4, for IdeaVIM and that is working well it seems, but I’d prefer to wait until the stable release before I recommend the upgrade of vim to the team.

    • Janett says:

      Hi Olof, what do you mean with “The zero latency typing.”? Did previous versions not have zero latency typing, and now they added it?

    • Janett says:

      @Olof, what do you mean with “The zero latency typing.”? Did previous versions not have zero latency typing, and now they added it?

      @Jetbrains, why are my comments always deleted? Do you not allow questions? I’m being serious here.

      • Anastasia Kazakova says:

        Comment are not deleted. First time for each user the pre-moderation is working. But after the first approve, your comments will be by default visible right away.

        • Janett says:

          I see – but the weird thing was that the “Currently being moderated” message disappeared, it was not there anymore, but my comment wasn’t either. So I (rightly) concluded that my comments were disapproved.

  2. Martin S. says:

    Disassembly view, I love it! Is it possible to show registers value in steps, instead of writing “display $esi” (etc.) in gdb? Thanks!

  3. Michael Lojkovic says:

    I don’t see the keymap for debugging disassembly in settings. What are the hotkeys for debugging assembly while using Visual Studio hotkeys?

  4. Harry Wong says:

    Congratulations! Very very great job!

  5. Sebastian says:

    Hi Anastasia,

    this is a great release. Now I am looking forward to see the 2017.2 road map.

    One thing that I would like for 2017.2 to see is the ability to connect the selected tool chain (e.g. MSVC, MinGW, Cygwin) and my CMake configurations (e.g. Debug, Release, etc.).

    For example for MSVC I need to set CMAKE_PREFIX_PATH to C:\Qt\5.3\msvc2013_64, whereas for MinGW I need to set it to C:\Qt\5.3\mingw482_32. It seems there is currently no easy way to switch between these configurations, so when I want to change the tool chain, then I need to update the CMake configuration. Additionally to execute the binary I need to set QTDIR and adjust the PATH to include %QTDIR%\bin. I cannot set this globally in Windows because depending on whether I build with MinGW or MSVC I need to have a different QTDIR path set.

    It would be great if under “Build, Execution, Deployment” -> CMake, I could select the tool chain in the CMake generation section. Then when I switch from MinGW to MSVC CLion could automatically select the CMake configuration for the matching tool chain.

    • Anastasia Kazakova says:

      This is a part of the following task: https://youtrack.jetbrains.com/issue/CPP-8893, which is in our plans now.

      • Michael Lojkovic says:

        There’s a similar issue with cores used for compiling. It would be really cool if we could just give the thread count, and not have to edit the thread count in build options. Maybe, add a macro that saves build options for each compiler target?

        • Anastasia Kazakova says:

          Not sure what you want to achieve. If we implement CMake defaults, you’ll be able to configure the number of cores (as a default value) for your IDE instance.

    • Dariusz says:

      Hey, would you mind sharing how did u got QT to work? I’m trying to use QT x64 via msvc but so far I’m getting “cannot find QObject” when trying to include them. I added my msvc2017 paths to windows path as well as in cmake but so far no luck…

  6. Jan Möller says:

    This is great, but since updating, all text is unreasonably large for me. This includes the code editor and the build-message/cmake message windows. I found a way to reduce the font size of the code editor via the settings menu, but no luck of getting an acceptable size for the build messages.
    I’m on Ubuntu 16.04 and I have upgraded from the latest EAP (which didn’t have this issue) by ways of the JetBrains Toolbox. I hope there will be a fix for this soon, because currently CLion is downright unusable for me.

  7. HGH says:

    I am curious how would these features transfer to Android Studio?

    • Anastasia Kazakova says:

      Language support will come to AS, but I can’t provide you any estimates, as it depends on Google. You are free to ask them about the estimations.

  8. Kirill S. says:

    Hello, zero-latency typing is great for comfortable working. I think everyone now is waiting for disasm on demand.
    I have a question: is it possible to use custom gdb targets from IDE? Not “target remote”, but custom?

  9. Mustafa says:

    i download the new v of clion 2017.1 but i still don’t have microsoft cmpiler support

    https://drive.google.com/file/d/0B8zUR_ggDqKvdUUwekNoTHBfUmc/view?usp=sharing

  10. Julio Jair says:

    Hello, could you help me,
    I just want to know how to turn off the disassembly view..

    • Anastasia Kazakova says:

      It’s not possible for now, it switches automatically when you step into the code with no sources. We are gonna make special step action to avoid such situation in future.

      • Julio Jair says:

        Thank you, and is there any way to avoid that?,
        I was working with the debugger in the previous version well, I don’t understand what you mean with “code with no sources”.

        • Marek Lukáš says:

          I’m with you on this. In previous versions, debugging was working logically as it should. Now, whenever I want to step into basically any function, I get into the disassembly view. It basically completely broke my debugging so I had to downgrade to 2016.3.4

          • Anastasia Kazakova says:

            This should be covered under https://youtrack.jetbrains.com/issue/CPP-8978.
            But how you were using it before? Why can’t you press the step over action in that situation?

          • Olof says:

            Stepping over works as before, but consider this call:

            smartPointerThingy->reverseStdString(“otto”);

            To go into this function goes into disassembly twice until I’m inside the function.

            Once for the smart pointer dereference and once to convert the char pointer to a std::string, I think, cursory analysis.

        • Anastasia Kazakova says:

          Currently no. If you press “Step Into” on a function that you don’t have sources for (library for example) you’ll jump into disassembly code now.

  11. Michael Lojkovic says:

    For the precompiled headers, would including stl headers in pch.h work for the syntax shown, or do I have to add an -include for each header I’m putting in pch.h?

    • vasily_romanikhin says:

      You don’t have to pass each stl-header mentioned in the pch.h via -include option.
      You сan list all appropriate includes in the pch.h, than compile it and then pass path to the precompiled header using -include. Here’s an example how to compile and use PHC: https://clang.llvm.org/docs/UsersManual.html#generating-a-pch-file

      • Michael Lojkovic says:

        Is this the correct way to set it up through cmake?
        https://gist.github.com/Zerophase/6724b0073822667c08dcd4dee1ef3418

        • vasily_romanikhin says:

          In general the described example seems correct.

          Also you can check the follow project which allows to add PCH to your CMake project: https://github.com/nanoant/CMakePCHCompiler

          • Michael Lojkovic says:

            I was able to get the CMake plugin cotire to work for handling the pch file and compiling successfully, but it causes issues with breaking CLion code completion, unless I include the pch with every header.

            The plugin you suggested doesn’t seem to support clang on Linux. I also tried this one: https://github.com/larsch/cmake-precompiled-header

            I was successful with generating the pch file for clang, (after some modifications) but kept getting an error about no suitable pch file in the pch folder from clang.

            cotire for now seems like it might be the ideal means supporting pch files, since it also supports unity builds at least till CMake actually implements proper PCH support.

          • vasily_romanikhin says:

            I’ll check CMake plugin contire with CLion and reply you a little bit later.

          • vasily_romanikhin says:

            I checked contire plugin with CLion on simple project, there are two files
            main.cpp and common.h (the header which will be precompiled). In common.h I defined PCH_DEFINED_VALUE.
            Please note in main.cpp there is no explicit include of common.h, but it uses PCH_DEFINED_VALUE.

            0. in my example the name of the project (and executable target) is “contirePCH”
            1. In CMakeList.txt I put the follow lines:
            set (CMAKE_MODULE_PATH “${CMAKE_SOURCE_DIR}/CMake”)
            include(cotire)
            set_target_properties(contire_PCH_example PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT “common.h”)
            cotire(contirePCH)
            2. Then run “contirePCH_unity” (or just “contirePCH”) configuration, it generates
            contirePCH_CXX_prefix.cxx and contirePCH_CXX_prefix.hxx in cmake-build-debug/cotire folder.
            3. And then reload CMake project (Tools->CMake->Reload_Project), now resolve and completion works correctly.
            You can find this example here: https://github.com/bac1ca/contire_PCH_example

            If it doesn’t help you please submit an issue with problem description or just ping me here and I’ll create it.

          • Michael Lojkovic says:

            Yeah, I’ll start an issue tracker for cotire in a couple days. Sometimes I have to reload the editor when including the PCH header with every file by default to get stl code completion working, and other libraries I’m building with the project under a separate directory their code completion stops working if they’re just in the PCH.

  12. Janett says:

    >> Olof: I think you forgot to bang your drum for the feature that in my opinion is by far the best improvement. The zero latency typing.

    I’m curious what is meant by this. Did it not have zero latency typing yet? How can any serious application even have non-zero latency typing?

Leave a Reply

Your email address will not be published. Required fields are marked *