which macro does gcc define beforehand ?

Eljay Love-Jensen eljay@adobe.com
Thu Oct 2 03:26:00 GMT 2003


Hi Daz,

On my Solaris 8 machine "gcc -v foo.c" (GCC 3.3.1) says it predefines these:
-D__GNUC__=3
-D__GNUC_MINOR__=3
-D__GNUC_PATCHLEVEL__=1
-Dsparc
-D__sparc__
-D__sparc
-D__GCC_NEW_VARARGS__

On my Linux Red Hat machine "gcc -v foo.c" (GCC 3.3.0) says it predefines these:
-D__GNUC__=3
-D__GNUC_MINOR__=3
-D__GNUC_PATCHLEVEL__=0
(Hmm, that's surprising!  No "OS" type of gimme define.)

On my Windows NT / Cygwin machine "gcc v foo.c" (GCC 3.3.1) says it predefines these:
-D__GNUC__=3
-D__GNUC_MINOR__=3
-D__GNUC_PATCHLEVEL__=1
-D__CYGWIN32__
-D__CYGWIN__
-Dunix
-D__unix__
-D__unix

If you want something that you can rely upon, I advise you to pass it in yourself.  I use things like:
-DMAC_PLATFORM
-DWIN_PLATFORM
-DUNIX_PLATFORM
...as appropriate.

HTH,
--Eljay




More information about the Gcc-help mailing list