QtCreator Cmake C++17 Features

  • So here I am, compiling my CMake-based C++ Projects in my terminal like there's not tomorrow with gcc-7.2.0 on Xubuntu 16.04 (via ppa)

    Everything works fine and the new features add considerable value to my codebase.

    However, trying to compile the very same project in qtcreator with the same compiler yields me errors like the following

    : error: expected ‘)’ before ‘;’ token
       if (auto event = events_.find(eventName); event == end(events_)) {
    : error: ‘else’ without a previous ‘if’
       } else {

    if trying to compile initializer-ifs. I tried to manually pick gcc-7 in the build&run section in qtCreators options but without success. So my question is this:

    What do I have to adjust in the IDE to make it conform to this latest standard?

  • Lifetime Qt Champion

    @Sewing You need to activate C++11 (I think it is even C++17). With qmake based projects you add this to pro file:

    CONFIG += c++11

    Not sure about CMake.

  • Lifetime Qt Champion


    Since Qt 5.7, C++11 being mandatory this CONFIG line is not necessary anymore unless you are targeting older versions of Qt.

    You can however ask for a more recent version of the standard with c++14 and c++17.

    Did you setup your cmake project to use c++17 ? If so, how did you do it ?

    What version of Qt Creator are you using ?

Log in to reply