Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtCreator Cmake C++17 Features
Forum Update on Monday, May 27th 2025

QtCreator Cmake C++17 Features

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sewing
    wrote on last edited by
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • S Sewing

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        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 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved