Jump to content
  • Advertisement
Sign in to follow this  
TeamWhore

linux compiler #define?

This topic is 5407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Quick question...is there a standard defined symbol when compiling in linux? I mean something like
#ifdef _LINUX
//do linux stuff
#else //windows etc
//do other stuff
#endif

I thought there was a standard one but I've come across 3 or 4 in the past few days, and I'm getting tired of saying "#ifndef _WIN32" I've seen _LINUX, __LINUX__, _LINUX_, and just plain LINUX and linux

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure if there is a "standard" one - as a matter of fact I doubt it - since I can't see OS macros being part of the language spec.

Since you're usually compiling with a makefile on linux anyways, just choose a single macro and stick with it - then add -D_LINUX or the like into the compile options - this is how most packages deal with this on linux I believe anyways.

If you want something "automatic" look into some of the standard headers on a linux box. Just be warned, those macros are probably not guaranteed to be in place - and eventually someone will probably complain about it not compiling on some really weird specialized system.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!