www.delorie.com/djgpp/v2faq/faq056.html   search  

| Previous | Next | Up | Top |

8.6 Writing codes fragments which are specific to DJGPP

Q: I must put a DJGPP-specific code fragment into my program. What symbol should I use in the #ifdef directive to make it only visible under DJGPP?


A: Use __DJGPP__, like this:

         #ifdef __DJGPP__
         ... DJGPP-specific code ...
         #else
         ... not seen under DJGPP ...
         #endif

__DJGPP__ has the value of the DJGPP major revision number, so you can write code fragments which have different behavior under different versions of DJGPP:

         #ifdef __DJGPP__
         #if __DJGPP__ > 2
         .... will work only in DJGPP v3.x and later ...
         #else
         .... get here for DJGPP v2.x ...
         #endif
         #else
         .... get here in DJGPP v1.x or non-DJGPP environment
         #endif

If you need to distinguish between minor DJGPP revision numbers, use the symbol __DJGPP_MINOR__. For example:

         #if defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ == 1
         .... will work only in DJGPP v2.01 ....
         #endif

Another DJGPP-specific pre-processor symbol which DJGPP defines is __GO32__; but it is only provided for compatibility with previous versions of DJGPP (v1.x) and its use should be discouraged.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)