Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 572
Ashika Umanga Umagiliya Avatar asked Oct 24 '25 18:10

Ashika Umanga Umagiliya


1 Answers

Compilers usually have a predefined macro for this.

#if defined(__GCC__)
  //do gcc related
#elif defined(_MSC_VER)
  //do msvc related
#else

#endif
like image 90
Marlon Avatar answered Oct 26 '25 07:10

Marlon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!