When I compile a project under Qt Creator 2.8 / Qt5.1 with VS 2010 all is fine. If I do the same with MinGW I get the following error.
error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
I understand I need to enable C+11, but I have CONFIG += console c++11
in my .pro file. Is this not what is needed? What am I doing wrong?
When I look at the make I see:
CXXFLAGS = -pipe -fno-keep-inline-dllexport -g -std=c++0x
Confusing, as I say c++11 in the pro file.
qmake
etc, from the scratch, no resultChecked:
Found solution, but can only accept it in some time: https://stackoverflow.com/a/19530028/356726
qmake got support for CONFIG += c++14 with Qt 5.4, so you can use that for projects where you are comfortable with requiring at least that version of Qt. Be sure to either use the explicit compiler flags, or use the CONFIG option, but not both at the same time, to avoid conflicting switches.
In the Qt docs it says that a qreal is a. Typedef for double unless Qt is configured with the -qreal float option. This basically means almost always double but float on ARM devices.
Qt Creator is not a compiler. When you read that "Qt Creator supports C++11" it means that the code-completion engine (Clang in this case) supports C++11 syntax.
# define Q_UNUSED(x) (void)x; To disable unused variable warnings. You can use the variable after this macro without any problem. However, if you pass an expression or something else to the macro and the compiler has to evaluate the expression it may has side effects† . Follow this answer to receive notifications.
Ok, thanks to your hints I have figured it out.
After I have tried any possible advice from above, with still no success, I have excluded any subproject I could think of in my project. Eventually I have found a QML sample .pro which did not have CONFIG += c++11
defined.
That was causing the error. So the root cause was not the project I was working on, but a subproject which however got compiled in the same step.
Try changing the mkspecs/win32-g++/qmake.conf
line that says:
QMAKE_CXXFLAGS_CXX11 = -std=c++0x
to:
QMAKE_CXXFLAGS_CXX11 = -std=c++11
and re-run qmake.
Some additional details:
Adding the "c++11" feature to the CONFIG
qmake variable causes the mkspecs/features/c++11.prf
file to be pulled in (see the "Adding New Configuration Features" section of the qmake Advanced Usage document for details).
That qmake profile has a QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_CXX11
line among other things which configure C++11 support. So adding "c++11" to the CONFIG variable is the proper way to indicate that you want c++11 support to qmake, as you mentioned in a comment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With