Home >Backend Development >C++ >How to Enable C 11 Support in Qt Creator?
Enabling C 11 in Qt Creator
When attempting to compile C 11 code in Qt Creator 2.7.0, users may encounter the error "range based for loops are not allowed in c 98 mode." This issue arises because Qt Creator's default C standard is set to C 98. To resolve this and enable C 11 support, follow the steps outlined below:
Method 1 (Qt 5 and above):
As per Qt's official documentation, for Qt 5 and above, add the following line to your .pro file:
CONFIG += c++11
Method 2 (Qt 4.8 and below):
For Qt 4.8 and earlier versions, along with gcc or clang compilers, use the following line in your .pro file:
QMAKE_CXXFLAGS += -std=c++11
Alternatively, you can also use:
QMAKE_CXXFLAGS += -std=c++0x
By implementing these changes, you can successfully enable C 11 support in Qt Creator and avoid the error associated with using C 11 features with the default C 98 standard.
The above is the detailed content of How to Enable C 11 Support in Qt Creator?. For more information, please follow other related articles on the PHP Chinese website!