Is there a preprocessor macro for hiding code from the Visual Studio Code parser?

1 day ago 3
ARTICLE AD BOX

If you use VSCode's C/C++ extension, you can define it on your own in .vscode/c_cpp_properties.json:

{ "configurations": [ { "name": "Linux", "intelliSenseMode": "linux-gcc-x64", "compilerPath": "/usr/bin/g++-15", "defines": [ "__VSCODE__=1" ] } ], "version": 4 }

Now edit a file like this:

#ifdef __VSCODE__ constexpr auto x = 1; #else constexpr auto x = 2; #endif static_assert(x == 1);

You will find that in VSCode there is an error squiggle on the static assertion, but if you compile it normally there are no errors.

GKxx's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Read Entire Article