For C/C++ syntax highlighting in vscode : how to tell vscode that a compile option "-Dxxxx" will be used?

1.2k Views Asked by At

When developing for micro controller, we use a lot of compile-time defines passed to the compiler with the "-Dxxxx" syntax. I would like to configure vscode such that it knows that certain defines will be provided and such that it highlights code properly corresponding to those info.

How would I do that ?

1

There are 1 best solutions below

2
On

I am assuming you have C/C++ extension installed.

1 - Open Command Palette by Ctrl + Shift + P or View -> Command Palette...
2 - Select C/C++: Edit Configurations (UI)
3 - Scroll down to Defines section, where you can add your defines/macros.

Also, In this tab you can tell vscode about your compiler options such as, the compiler arguments, the language standard you are using, include paths, etc.