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. "CONFIG += c++11" in .pro however "-std=gnu++0x" in Compile output
QtWS25 Last Chance

"CONFIG += c++11" in .pro however "-std=gnu++0x" in Compile output

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 10.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.
  • fxchF Offline
    fxchF Offline
    fxch
    wrote on last edited by fxch
    #1

    Hi,

    My .pro has the CONFIG += c++11 statement however compile output shows the flag -std=gnu++0x.
    I'd like to know if it's correct and if the compiler actually is compiling c++11 or c++0x. Thank you.
    Alt text

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

      Hi and welcome to devnet,

      Did you re-run qmake after adding c++11 to CONFIG ? Also, what version of MinGW 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

      fxchF 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Did you re-run qmake after adding c++11 to CONFIG ? Also, what version of MinGW are you using ?

        fxchF Offline
        fxchF Offline
        fxch
        wrote on last edited by fxch
        #3

        @SGaist Hi,

        I entered in build folder and deleted all files :

        $ cd ~/cpp/build-untitled-Desktop_Qt_5_6_0_GCC_64bit-Debug/
        $ rm *
        

        After clicked Build >> Build All and the result was:

        19:47:01: Running steps for project untitled...
        19:47:01: Starting: "/home/christiano/Qt/5.6/gcc_64/bin/qmake" /home/christiano/cpp/untitled/untitled.pro -r -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
        19:47:01: The process "/home/christiano/Qt/5.6/gcc_64/bin/qmake" exited normally.
        19:47:01: Starting: "/usr/bin/make" 
        g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_CORE_LIB -I../untitled -I. -I../../Qt/5.6/gcc_64/include -I../../Qt/5.6/gcc_64/include/QtCore -I. -I../../Qt/5.6/gcc_64/mkspecs/linux-g++ -o Vector.o ../untitled/Vector.cpp
        g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_CORE_LIB -I../untitled -I. -I../../Qt/5.6/gcc_64/include -I../../Qt/5.6/gcc_64/include/QtCore -I. -I../../Qt/5.6/gcc_64/mkspecs/linux-g++ -o main.o ../untitled/main.cpp
        g++ -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath,/home/christiano/Qt/5.6/gcc_64/lib -o untitled Vector.o main.o   -L/home/christiano/Qt/5.6/gcc_64/lib -lQt5Core -lpthread 
        19:47:03: The process "/usr/bin/make" exited normally.
        19:47:03: Elapsed time: 00:02.
        

        I am using Linux RHEL 7.2 and Qt Creator 3.6.1.

        1 Reply Last reply
        0
        • Paul ColbyP Offline
          Paul ColbyP Offline
          Paul Colby
          wrote on last edited by
          #4

          Would you mind showing the output of:

          cat /home/christiano/cpp/untitled/untitled.pro
          

          I know it should be the same as the image you included above, but I'd like to be able to cut-and-paste it into a file to test locally.

          Thanks :)

          fxchF 1 Reply Last reply
          0
          • Paul ColbyP Paul Colby

            Would you mind showing the output of:

            cat /home/christiano/cpp/untitled/untitled.pro
            

            I know it should be the same as the image you included above, but I'd like to be able to cut-and-paste it into a file to test locally.

            Thanks :)

            fxchF Offline
            fxchF Offline
            fxch
            wrote on last edited by fxch
            #5

            @SGaist @Paul-Colby Hi,
            I think I understood:


            $ man g++

            ...
            -std=
            Determine the language standard. This option is currently only supported when compiling C or C++. The compiler can accept several base standards, such as c90 or c++98, and GNU dialects of those standards, such as gnu90 or gnu++98. When a base standard is specified, the compiler accepts all programs following that standard plus those using GNU extensions that do not contradict it. For example, -std=c90 turns off certain features of GCC that are incompatible with ISO C90, such as the "asm" and "typeof" keywords, but not other GNU extensions that do not have a meaning in ISO C90, such as omitting the middle term of a "?:" expression. On the other hand, when a GNU dialect of a standard is specified, all features supported by the compiler are enabled, even when those features change the meaning of the base standard. As a result, some strict-conforming programs may be rejected. The particular standard is used by -Wpedantic to identify which features are GNU extensions given that version of the standard. For example -std=gnu90 -Wpedantic warns about C++ style // comments, while -std=gnu99 -Wpedantic does not.
            A value for this option must be provided; possible values are
            ...
            c++11
            c++0x

            The 2011 ISO C++ standard plus amendments. Support for C++11 is still experimental, and may change in incompatible ways in future releases. The name c++0x is deprecated.
            ...
            gnu++11
            gnu++0x

            GNU dialect of -std=c++11. Support for C++11 is still experimental, and may change in incompatible ways in future releases. The name gnu++0x is deprecated.


            Therefore gnu++0x, as well as gnu++11, are GNU dialects of the same ISO C++ standard: the 2011; the first being a std value deprecated.

            Anyway, below the .pro

            
            QT += core
            QT -= gui
            
            CONFIG += c++11
            
            
            TARGET = untitled
            CONFIG += console
            CONFIG -= app_bundle
            
            TEMPLATE = app
            
            SOURCES += \
                Vector.cpp \
                main.cpp
            
            HEADERS += \
                Vector.h
            

            Thank you!

            _ 1 Reply Last reply
            2
            • Paul ColbyP Offline
              Paul ColbyP Offline
              Paul Colby
              wrote on last edited by
              #6

              @fxch said:

              Therefore gnu++0x, as well as gnu++11, are GNU dialects of the same ISO C++ standard: the 2011; the first being a std value deprecated.

              Yep, looks like you are correct.

              qtbase/mkspecs/common/g++-base.conf [Qt 5.6]:

              QMAKE_CXXFLAGS_CXX11    = -std=c++0x
              QMAKE_CXXFLAGS_CXX14    = -std=c++1y
              QMAKE_CXXFLAGS_CXX1Z    = -std=c++1z
              QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++0x
              QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y
              QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
              

              qtbase/mkspecs/common/g++-base.conf [Qt 5.7]:

              QMAKE_CXXFLAGS_CXX11    = -std=c++11
              QMAKE_CXXFLAGS_CXX14    = -std=c++1y
              QMAKE_CXXFLAGS_CXX1Z    = -std=c++1z
              QMAKE_CXXFLAGS_GNUCXX11 = -std=gnu++11
              QMAKE_CXXFLAGS_GNUCXX14 = -std=gnu++1y
              QMAKE_CXXFLAGS_GNUCXX1Z = -std=gnu++1z
              

              Cheers.

              1 Reply Last reply
              1
              • fxchF fxch

                @SGaist @Paul-Colby Hi,
                I think I understood:


                $ man g++

                ...
                -std=
                Determine the language standard. This option is currently only supported when compiling C or C++. The compiler can accept several base standards, such as c90 or c++98, and GNU dialects of those standards, such as gnu90 or gnu++98. When a base standard is specified, the compiler accepts all programs following that standard plus those using GNU extensions that do not contradict it. For example, -std=c90 turns off certain features of GCC that are incompatible with ISO C90, such as the "asm" and "typeof" keywords, but not other GNU extensions that do not have a meaning in ISO C90, such as omitting the middle term of a "?:" expression. On the other hand, when a GNU dialect of a standard is specified, all features supported by the compiler are enabled, even when those features change the meaning of the base standard. As a result, some strict-conforming programs may be rejected. The particular standard is used by -Wpedantic to identify which features are GNU extensions given that version of the standard. For example -std=gnu90 -Wpedantic warns about C++ style // comments, while -std=gnu99 -Wpedantic does not.
                A value for this option must be provided; possible values are
                ...
                c++11
                c++0x

                The 2011 ISO C++ standard plus amendments. Support for C++11 is still experimental, and may change in incompatible ways in future releases. The name c++0x is deprecated.
                ...
                gnu++11
                gnu++0x

                GNU dialect of -std=c++11. Support for C++11 is still experimental, and may change in incompatible ways in future releases. The name gnu++0x is deprecated.


                Therefore gnu++0x, as well as gnu++11, are GNU dialects of the same ISO C++ standard: the 2011; the first being a std value deprecated.

                Anyway, below the .pro

                
                QT += core
                QT -= gui
                
                CONFIG += c++11
                
                
                TARGET = untitled
                CONFIG += console
                CONFIG -= app_bundle
                
                TEMPLATE = app
                
                SOURCES += \
                    Vector.cpp \
                    main.cpp
                
                HEADERS += \
                    Vector.h
                

                Thank you!

                _ Offline
                _ Offline
                _PIB
                wrote on last edited by _PIB
                #7

                @fxch this bugs me as well. Qmake puts GNU dialect for whatever reason both with CONFIG += c++11 and without it.

                I have my mkspec modified so I noticed that QMAKE_CXXFLAGS_GNUCXX11 is used by Qmake for whatever reason (this whole variable is fed to compiler).

                Of course it does not matter largely but I would rather like to have control over dialect used.

                QT v5.8.0

                1 Reply Last reply
                0
                • _ Offline
                  _ Offline
                  _PIB
                  wrote on last edited by _PIB
                  #8

                  Convenient solution was:

                  CONFIG+= strict_c++ c++11

                  This would disable GNU dialect before C++11.prf was removed from source tree:
                  https://git.merproject.org/mer-core/qtbase/blob/041fae00351164fbd72763e4bd947fdeb9956a5d/mkspecs/features/c++11.prf

                  So, now you can only disable gnu extensions by modifying mkspec file.

                  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