I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » Tutorials » C & C++ » Advanced »

Compiler directives (#ifdef's) to isolate specific compilers

will\′s Photo
12 Jan 08, 1: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
 
#endif

Microsoft C++
#ifdef _MSC_VER
  // Microsoft C++
 
#ifdef _MANAGED
#if (_MANAGED)
  // Managed
#else
  // Unmanaged
#endif
#else
  // Unmanaged
#endif
#endif

Borland C++
#ifdef __BCPLUSPLUS__
  // Borland C++ 
#endif

Digital 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

Currently you need to be logged in to leave a message.