C ++ 14 support in QtCreator with Clang

How to enable C ++ 14 support in QtCreator 3.3 using Clang 3.5? I added the Clang suite, and I added CONFIG += c++14 to my project file. However, when using, for example, return type deduction, I get the following error:

error: "auto" return without return type; inferred return types are an extension of C ++ 1y

+5
source share
2 answers

I needed to go into the Makefile in the build folder and manually replace -std=c++11 with -std=c++14 .

Fortunately, a Makefile is written only once when you add a kit to a project. I only had to do this once and could build in QtCreator as many times as I want.

So now I can use the Clang suite to take advantage of all the new features of C ++ 14. As a bonus, I can also use all the features of C ++ 17 if I manually set -std=c++1z to the Makefile. Cool!

+3
source

you can use CONFIG += c++14 in a .pro file with Qt5.5

but there is an error with clang, so we need to change the file Qt/5.5/clang_64/mkspecs/features/c++14.prf add this code before include(c++11.prf) :

 contains(QMAKE_LFLAGS_CXX11, -stdlib=libc++) { QMAKE_CXXFLAGS_CXX11 += -stdlib=libc++ } 
+6
source

Source: https://habr.com/ru/post/1210719/


All Articles