"CONFIG += c++11" in .pro however "-std=gnu++0x" in Compile output
-
Hi and welcome to devnet,
Did you re-run qmake after adding
c++11
toCONFIG
? Also, what version of MinGW are you using ? -
@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.
-
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 :)
-
@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!
-
@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.
-
@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
-
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.prfSo, now you can only disable gnu extensions by modifying mkspec file.