c++visual-studiovisual-c++marmalade

how to undefine _MSC_VER?


I work in Visual Studio but my project is for a POSIX-based environment (marmalade sdk). In this project, the release build is compiled with gcc for ARM but the debug version works on windows and is compiled by MS compiler. Also this environmet has its own implementation of STL and other standard libraries.

Many of these c++ librares have code like this:

#if defined( _MSC_VER )
   #include <Windows.h>
#else
   #include <pthread.h>
#endif

Is it possible to undefine the _MSC_VER macro? - So that the C++ libraries will detect a POSIX system here.


Solution

  • Of course:

    #undef _MSC_VER
    
    #if defined( _MSC_VER )
       #include <Windows.h>
    #else
       #include <pthread.h>
    #endif
    

    Or, #undef it before you include the file where _MSC_VER is used.