Question

I use Visual Studio 2012 to edit source code that is targeting Linux. The problem is that syntax highlighting gets it all wrong, because it thinks _WIN32, _MSC_VER, and similar macros are defined. What can I do to get rid of them?

I tried two methods:

  1. added /u command in the property page for C++;
  2. added /U"_WIN32" /U"_MSC_VER" and so on.

but without any effect. The problem is the same in Visual Studio 2013.

What should I do?

Was it helpful?

Solution

These are compiler-predefined macros. You can only #undef them in the code. Use a custom header file, probably.

Anyway, the requirement seems strange to me. Why do you use MSVC if you want to scan the Linux code? If the Linux code uses any GCC extensions (it often does), it can't compile under MSVC at all.

OTHER TIPS

You can edit them in you're project's configuration.

Right click project->properties->C/C++->preprocessor->preprocessor definitions

I create a test project. The definitions only affected when the code be compiled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top