Reputation: 4765
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?
Upvotes: 6
Views: 3635
Reputation: 194
If you don't want the C++ extension to auto-configure your system includes & defines, you can set "compilerPath": ""
for your configuration in your c_cpp_properties.json
and the extension will stop auto-configuring you.
Upvotes: 0
Reputation: 12749
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.
Upvotes: 7