[SDL] conditional defines for OS

Guido Draheim guidod-2001q3 at gmx.de
Tue Aug 7 13:16:01 PDT 2001


Samuel Hart wrote:
> 
> On Tuesday 07 August 2001 04:35pm, Roger Durañona Vargas wrote:
> > What compiling directives defines each C compiler/OS to identify
> > current platform?
> 
> This is something else which should be made into a FAQ somewhere ;-)
> 
> Actually, a pretty good place to look for some of them, is in the SDL_syswm.h
> or SDL_main.h header files.
> 
> It seems that GCC defines a"__UNIX__", "__LINUX__", "__BEOS__" and some other
> things (depending on your platform. I may be wrong on these.... they're just
> off the top of my head).
> 
> Also, I think there is a "WIN32" that MSVC++ defines.
> 
> The rest, Idunno.


a) use "gcc -dumpspecs" to find out what gcc will defined for 
   a given platform. Most compilers will have a similar option.
b) there is a long long tradition that unixish systems have a predefined
   "unix" and winfish systems have a _WIN32 predefined. Even if you do not 
   know about the other OS flavours, one can still differentiate between 
   unixish and winfish environments. Sadly, that does still not target
   beos and macs as the ones with less flavours of its OS kind.
c) before trying to identifying the compiler, always check __STDC_VERSION__
   which is far more important than any compiler specifics, and otherwise 
   expect compilers to have their name defined in between doubled underscores,
   preferring the vendor name plus C over any marketing name, that is...
   __GNUC__,__BORLANDC__,__WATCOMC__,etc... as this was induced by ansi-c 
   common predefiner rules.

cheers,
-- guido            [you must go and see it, http://www.mingw.org revived]
GCS/E/S/P C++$++++ ULHS L++w- N++@ d(+-) s+a- r+@>+++ y++ 5++X- (geekcode)



More information about the SDL mailing list