[SOLVED] C++11 flags get constantly ignored by compiler
-
Hi,
i am trying to compile a lib which is written in C++ using c11 features.
My System is Ubuntu 14.04, QT5.4.1 and g++4.9I have tried out all types of flag settings i could find like
QMAKE_CXXFLAGS += -std=c++11
or
CONFIG += c++11
in the .PRO file, like i found it here on the forum
everything gets ignored and the same build error comes up:
error: 'for' loop initial declarations are only allowed in C99 or C11 mode
use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your codeAnybody any hint?
-
@developSomething
Did you rerun qmake in Qt creator?
Sometimes this helps. -
I had a similar problem. I was getting this #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. when i added a library to my project. A couple of hours later i saw your post and went to /opt/Qt5.4.1/5.4/gcc_64/mkspecs/linux-g++ and chenged qmake.conf, replaced the line CONFIG += incremental with this line CONFIG += c++11 incremental and then surprise, it workd.But still i get a litle warning: libGL error: failed to load driver: swrast dunno what's that about but my program warks fine. Im running linux mint 64 bit. Hope it helps.
-
I found out that all compiler settings get ignored as long as the source files have the *.c extension.
So renaming all files to cpp was the solution -
@developSomething
Most compilers are using the file extension to detect the programming language. Probably a result of several stages of language detection. Because you must have C++ statements in a C. I thought the compiler would complain with a different warning at least.Also it was asking for C11 mode. This seems to be for C. While you were trying to apply c++11, this is for C++11.