Is there a preprocessor define that is defined if the compiler is MSVC?
C++Visual C++C PreprocessorC++ Problem Overview
So I can do something like
#ifdef MSVC
//do compiler specific code here
#endif
C++ Solutions
Solution 1 - C++
It's _MSC_VER. More info at MSDN and at predef.
But, be aware that some other compilers may also define it, e.g. Intel's C++ Compiler for Windows also defines _MSC_VER. If this is a concern, use #if _MSC_VER && !__INTEL_COMPILER
.
Solution 2 - C++
Look at the list of MSVC predefined macros. You'll find what you need.
_MSC_VER
is probably a good one.
Solution 3 - C++
_MSC_VER
should fit your needs
Solution 4 - C++
_MSC_VER is one such predefined macro.