C++14 support in QtCreator with Clang

ⅰ亾dé卋堺 提交于 2019-12-03 15:42:28

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!