How can I enable C++14 support in QtCreator 3.3 using Clang 3.5? I have added a Clang kit and I have added CONFIG += c++14
in my project file. However when using e.g. return type deduction I get the following error:
error: 'auto' return without trailing return type; deduced return types are a C++1y extension
you can use CONFIG += c++14
in .pro
file with Qt5.5
but there is a bug with clang, so we need to modify the Qt/5.5/clang_64/mkspecs/features/c++14.prf
file,
add this code beforeinclude(c++11.prf)
:
contains(QMAKE_LFLAGS_CXX11, -stdlib=libc++) {
QMAKE_CXXFLAGS_CXX11 += -stdlib=libc++
}
I had to go to the Makefile in the build folder and manually replace -std=c++11
with -std=c++14
.
Thankfully the Makefile is only written once when you add the kit to the project. I only had to do this once and could build in QtCreator as often as I want.
So now I can use a Clang kit to use all the new c++14 features. As a bonus, I can also use all the c++17 features if I manually set -std=c++1z
in the Makefile. Sweet!
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