I'm currently using C++11 features in my Qt applications. However, I'd like to use some of the new C++14 features in my applications.
To enable C++11 in a Qt application, one only needs to add one line in the qmake project file, namely:
CONFIG += c++11
or this for earlier versions:
QMAKE_CXXFLAGS += -std=c++1y
I already tried to do the same with C++14, but it didn't work. I changed the above mentioned line of the qmake project like this:
CONFIG += c++14
or this for earlier versions:
QMAKE_CXXFLAGS += -std=c++1y
After that, lots of compilation errors, that did not exist before, appear when trying to build the project. The project compiles fine, however, if I try to use any C++14 features, I get a compilation error. This is an example:
template<typename T>
constexpr T pi = T(3.1415926535897932385);
This is the corresponding error:
main.cpp:7: error: template declaration of 'constexpr const T pi'
constexpr T pi = T(3.1415926535897932385);
^
How to enable C++14 features when using a qmake project in QtCreator?
I am using Qt 5.3.2, Qt Creator 3.2.1, and MinGW 4.8.2 32 bit.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…