开发者

Flag to check whether the compiler is gcc/mingw or VC++ cl? [duplicate]

This question already has answers here: Closed 11 years ago.

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜