Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code not highlighting #if.. in C++

I try to get VS-Code working for my C++ project, but I have the problem that the syntax highlighting ignores preprocessor directives like #if/#else/#endif.

I have the extensions ms-vscode.cpptools (C/C++) and ext install code-gnu-global (Intellisense) installed.

"Go To Definition" shows the #define correctly.

enter image description here

#define ON_TARGET false results to the same highlighting

It should look like this:

enter image description here

like image 816
thetemplar Avatar asked Apr 28 '26 04:04

thetemplar


2 Answers

VS Code can do it with Microsoft's C/C++ extension since v 0.15 from February 2018.

enter image description here

like image 66
Joel Santos Rico Avatar answered Apr 30 '26 16:04

Joel Santos Rico


Visual Studio Code can't do such things out of the box as it is "just" an editor.

If you compile your code, it will work as expected.

For evaluating such defines you need an IDE, e.g. Visual Studio, CLion or you may achieve this with additional Plugins. (e.g. C/C++ Plugin)

like image 44
daB0bby Avatar answered Apr 30 '26 16:04

daB0bby