Possible Duplicate:
Detect compiler with #ifdef
Greetings all,
I've been working on a C++ project using gcc on linux and mingw on windows.Now I want to use VC++ cl compiler on Windows. I was to keep the same source code tree only change the compiler specific logic like:
#ifdef VC_CL_COMPILER
//do vc++ related
#elif MINGW_FLAG
//do mingw related
#elseif GCC_FLAG
//do gc related
#endif
Anyway tips on doing this?开发者_StackOverflow
Compilers usually have a predefined macro for this.
#if defined(__GCC__)
//do gcc related
#elif defined(_MSC_VER)
//do msvc related
#else
#endif
精彩评论