I know it is possible to add defines for Visual Studio Code in c_cpp_properties.json and I manually define __GNUC__
for my code, but is it possible to undo/remove defines that Visual Studio Code assumes for itself? For example if I set intelliSenseMode
to clang-x64
the macro __clang__
is defined which completely destroys my intellisense because I don't have appropriate include files for libraries I use and include selection for __clang__
happens before __GNUC__
. Same for msvc-x64
value. If I manually #undef __clang__
in my include files then everything is perfect.
Is it possible to undo macro in Visual Studio Code configuration?
First, create a header file called, say, vscode-preinclude.h
. Put it anywhere; I'll assume it is in the workspace folder (the one that also has .vscode
in it). Inside that file use #undef
to undefine the symbols you need turned off. Example:
#undef __clang__
Next, use the Command Palette (Ctrl+Shift+P) and open "C/C++: Edit Configurations (UI)". Go down to the bottom and open "Advanced Settings". Scroll down to "Forced include", and add a line:
${workspaceFolder}/vscode-preinclude.h
That's it!
If it doesn't work, take a look at the output of the "C/C++: Log Diagnostics" command. It should show something like:
Forced Includes:
D:\WRK\LEARN\VSCODE\CPPHELLO\VSCODE-PREINCLUDE.H
in its output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With