Conditional defines for OS

What compiling directives defines each C compiler/OS to identify
current platform?–
Roger D. Vargas
ICQ: 117641572
Linux User: 180787

This is something else which should be made into a FAQ somewhere :wink:

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.On Tuesday 07 August 2001 04:35pm, Roger Dura?ona Vargas wrote:

What compiling directives defines each C compiler/OS to identify
current platform?


Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >

Samuel Hart 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 :wink:

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)> On Tuesday 07 August 2001 04:35pm, Roger Dura?ona Vargas wrote: