# Conditional defines for OS

**URL:** <https://discourse.libsdl.org/t/conditional-defines-for-os/4863>\
**Category:** SDL Development\
**Created:** [August 7, 2001, 10:55am UTC](https://discourse.libsdl.org/t/conditional-defines-for-os/4863 "2001-08-07T10:55:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger\_D\_Vargas](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/roger_d_vargas/32/70_2.png) [@Roger\_D\_Vargas](https://discourse.libsdl.org/u/Roger_D_Vargas)\
**Post date:** [August 7, 2001, 10:55am UTC](https://discourse.libsdl.org/t/conditional-defines-for-os/4863/1 "2001-08-07T10:55:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sam\_Hart](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@Sam\_Hart](https://discourse.libsdl.org/u/Sam_Hart)\
**Post date:** [August 7, 2001, 11:49am UTC](https://discourse.libsdl.org/t/conditional-defines-for-os/4863/2 "2001-08-07T11:49:01Z")

</div>

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.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/](http://www.geekcomix.com/snh/) \>  
PGP Info: \< [http://www.geekcomix.com/snh/contact/](http://www.geekcomix.com/snh/contact/) \>  
Advogato: \< [http://advogato.org/person/criswell/](http://advogato.org/person/criswell/) \>

---

<div class="post-metadata">

**Author:** ![Guido\_Draheim](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/e19adc/32.png) [@Guido\_Draheim](https://discourse.libsdl.org/u/Guido_Draheim)\
**Post date:** [August 7, 2001, 1:16pm UTC](https://discourse.libsdl.org/t/conditional-defines-for-os/4863/3 "2001-08-07T13:16:01Z")

</div>

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 😉
> 
> 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](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:
