Compiler directives (#ifdef's) to isolate specific compilers
12 Jan 08, 7:34PM
Compiler directives (#ifdef's) to isolate specific compilers
Below are a list of different compiler defines that are handy to know when you need to write cross-compiler compatible code and need to isolate certain features to certain compilers.
GNU gcc
#ifdef __GNUC__ // GNU C #ifdef __GNUC_MINOR__ // GNU C MINOR #if __GNUC_PATCHLEVEL__ // GNU C PATCH LEVEL #endif #endif #endif #if (__CYGWIN32__ || __CYGWIN__) // CYGWIN #endif #if (__MINGW32__ || __MINGW__ ) // MINGW #endif #if (__DJGPP__) // DJGPP #ifdef __DJGPP_MINOR__ // DJGPP MINOR #endif #endif #endifMicrosoft C++
#ifdef _MSC_VER // Microsoft C++ #ifdef _MANAGED #if (_MANAGED) // Managed #else // Unmanaged #endif #else // Unmanaged #endif #endifBorland C++
#ifdef __BCPLUSPLUS__ // Borland C++ #endifDigital Mars C++
#ifdef __DMC__ #ifndef __DMC_VERSION_STRING__ #error __DMC_VERSION_STRING__ Not Defined #endif // Digital Mars C++ #endif
If you know of any others that should be assed, please reply to this message