简体   繁体   中英

Enable C++14 in QtCreator's [Clang]CodeModel

How do I enable C++14 in the ClangCodeModel (or even the "normal" one)?

I added CONFIG += c++14 in the .pro file and the project compiles fine with both gcc and clang but the IDE is annyoing me with spurious warnings on C++14 constructs.

When looking at the "C++ Code Model Inspector", the "Project Parts->General" tab says

Language Version CXX11

despite the config entry. It seems the IDE's CodeModel does not pick that up.

Go to Tools -> Options -> C++ -> Code Model.

Find the group "Clang Code Model Warnings" and "Copy" the current configuration ("Warnings for almost everything [built-in]" by default) in order to edit them.

In your new configuration add:

-std=c++14

to the end of the list of warnings and restart QtCreator. Just hitting apply or even refreshing the model does not work.

Afterwards the warnings should disappear. Let me know if it works!

I'm using Qt Creator 4.0.3 on Ubuntu 16.04.

The accepted answer didn't work for me because Qt Creator removes the non-warning flag automatically..

However if you have a CMake project you can just specify

set(CMAKE_CXX_STANDARD 14)

and it will work (using QT Creator 4.7.1 here).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM