[svlug] GCC predefined preprocessor values

Rick Kwan rick.kwan at lightsaber.com
Thu Jan 17 17:17:03 PST 2002

Hey folks,

I'm trying to compile some code with GCC on Linux, Solaris, and Mac
OS X.  Amazingly, I have access to all three.  I'm discovering quickly
that I want to use some OS-dependent preprocessor values.  The problem
is, I can't fine them.  I would like to be able to say
     #ifndef Darwin
         freehostent (hp);
except that "Darwin" is not recognized.  ("__MACH__" is.)  I haven't
been able to find this in the GCC documentation I've read so far
either.  It would be fun to say
         printf ("OS is %s\n", __OS__);
and have the right value come out, but I can't find anything of the
sort.  In fact, it would be really nice if these were reflective of
"uname -a".  So far, I can't fine any correlation.

Any ideas?

--Rick Kwan

More information about the svlug mailing list