Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    General and Desktop
    4
    8
    9556
    Loading More Posts
    • 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.
    • fxch
      fxch last edited by fxch

      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 Reply Quote 1
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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

        fxch 1 Reply Last reply Reply Quote 0
        • fxch
          fxch @SGaist last edited by fxch

          @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 Reply Quote 0
          • Paul Colby
            Paul Colby last edited by

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

            fxch 1 Reply Last reply Reply Quote 0
            • fxch
              fxch @Paul Colby last edited by 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!

              _ 1 Reply Last reply Reply Quote 2
              • Paul Colby
                Paul Colby last edited by

                @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 Reply Quote 1
                • _
                  _PIB @fxch last edited by _PIB

                  @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 Reply Quote 0
                  • _
                    _PIB last edited by _PIB

                    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 Reply Quote 1
                    • First post
                      Last post