Qt Creator C ++ 11 syntax highlighting for common projects

My main question is: when using Qt Creator as a code editor for "general" (not Qt) projects , how can I say to use C ++ 11 syntax highlighting?

I have a C ++ 11 project that I have been working on for some time, and decided that I would try Qt Creator. This is a simple vanilla C ++ project with a manually encoded make file, etc.

Qt Creator simply opened the project ("eSLIME") and created three files: eSLIME.config, eSLIME.includes and eSLIME.files. He did not create the .pro file.

It does not seem to recognize C ++ 11 calls. For example, it underlines " #include <unordered_set> " in green and indicates that there is no such file or directory.

I suspect that I should put something in the .config file, but I can’t understand that Google searches do not help either. I tried appending -std = C ++ 0x, which did not work.

PS: the code is too broken to build right now, so I switched to IDE.

+6
source share
2 answers

Qt 5.0.2 supports C ++ 11 syntax for any C ++ file, then

just download QT 5.0.2 (Qt Creator 2.7.0 is included).

+1
source

2 years passed through this question and answers, but nothing has changed in Qt Creator (at least for Linux): even the latest version (now 3.5) cannot parse C ++ 11 headers.

The problem is that by default __cplusplus in the internal Qt Creator parser is defined to a value less than 201103L, there are a lot of checks of this macro in the STL headers, for example:

 #if __cplusplus < 201103L #include <bits/c++0x_warning.h> // disable all tasty functionality #endif 

At first I tried to add to *. config the following line:

 #define __cplusplus 201103L 

Nothing happened.

After some research, I finally found the right solution: just write in *. config :

 #define __cplusplus 201103 

Magically everything becomes alive!

+7
source

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


All Articles