public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: which macro does gcc define beforehand ?
@ 2003-10-01 22:19 lrtaylor
  0 siblings, 0 replies; 5+ messages in thread
From: lrtaylor @ 2003-10-01 22:19 UTC (permalink / raw)
  To: silverdaz, gcc-help

I believe GCC defines "sun" on Solaris.  A nice easy trick to see what GCC defines by default is to touch a file (creating an empty one) and then run the following command:

gcc -c -E -dM file.c

or

g++ -c -E -dM file.cpp

where file.c and file.cpp are simply empty files.  This will print out all the defines.

Cheers,
Lyle

-----Original Message-----
From: Daz [mailto:silverdaz@yahoo.fr] 
Sent: Wednesday, October 01, 2003 4:14 PM
To: gcc-help@gcc.gnu.org
Subject: which macro does gcc define beforehand ?

Hi all,

I'm trying to find a macro for each platform I intend to use gcc.
On windows platform, _WIN32 is defined,
__APPLE__ or MACOSX are defined for the apple (powerpc) platforms.
I would like to find one macro for the solaris platform, which will be different than a linux one.

Basically, I'd like to do that
#ifdef __THE_MACRO__
#  define __MY_APP_PLATFORM_1__
#elif defined(__ANOTHER_MACRO__)
#  define __MY_APP_PLATFORM_2__
#endif
etc...
(It's somehow my way to "detect" which platform I'm running on.
If anyone has a better suggestion, feel free to tell me :) )

Thanks

@ + Daz

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: which macro does gcc define beforehand ?
@ 2003-10-02 13:39 Martin York
  0 siblings, 0 replies; 5+ messages in thread
From: Martin York @ 2003-10-02 13:39 UTC (permalink / raw)
  To: silverdaz, gcc-help


Make sure file.c and/or file.cpp are empty (I now its metioned below but I think it is worth mentioning again) or you will also print any defines that are defined in these files.

I also just want to emphasis what is implied below. That the defines for 'gcc -E -dM file.c' and 'g++ -E -dM file.cpp'  produces different outputs.

-----Original Message-----
From: lrtaylor@micron.com [mailto:lrtaylor@micron.com]
Sent: Wednesday, October 01, 2003 6:19 PM
To: silverdaz@yahoo.fr; gcc-help@gcc.gnu.org
Subject: RE: which macro does gcc define beforehand ?


I believe GCC defines "sun" on Solaris.  A nice easy trick to see what GCC defines by default is to touch a file (creating an empty one) and then run the following command:

gcc -c -E -dM file.c

or

g++ -c -E -dM file.cpp

where file.c and file.cpp are simply empty files.  This will print out all the defines.

Cheers,
Lyle

-----Original Message-----
From: Daz [mailto:silverdaz@yahoo.fr] 
Sent: Wednesday, October 01, 2003 4:14 PM
To: gcc-help@gcc.gnu.org
Subject: which macro does gcc define beforehand ?

Hi all,

I'm trying to find a macro for each platform I intend to use gcc.
On windows platform, _WIN32 is defined,
__APPLE__ or MACOSX are defined for the apple (powerpc) platforms.
I would like to find one macro for the solaris platform, which will be different than a linux one.

Basically, I'd like to do that
#ifdef __THE_MACRO__
#  define __MY_APP_PLATFORM_1__
#elif defined(__ANOTHER_MACRO__)
#  define __MY_APP_PLATFORM_2__
#endif
etc...
(It's somehow my way to "detect" which platform I'm running on.
If anyone has a better suggestion, feel free to tell me :) )

Thanks

@ + Daz

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: which macro does gcc define beforehand ?
  2003-10-01 22:14 Daz
@ 2003-10-02  3:26 ` Eljay Love-Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: Eljay Love-Jensen @ 2003-10-02  3:26 UTC (permalink / raw)
  To: Daz, gcc-help

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* which macro does gcc define beforehand ?
@ 2003-10-01 22:37 Daz
  0 siblings, 0 replies; 5+ messages in thread
From: Daz @ 2003-10-01 22:37 UTC (permalink / raw)
  To: gcc-help

I found ...

g++ -E -dM test.cc
will output the predefined symbols.

Thanks anyhow

@ + Daz

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* which macro does gcc define beforehand ?
@ 2003-10-01 22:14 Daz
  2003-10-02  3:26 ` Eljay Love-Jensen
  0 siblings, 1 reply; 5+ messages in thread
From: Daz @ 2003-10-01 22:14 UTC (permalink / raw)
  To: gcc-help

Hi all,

I'm trying to find a macro for each platform I intend to use gcc.
On windows platform, _WIN32 is defined,
__APPLE__ or MACOSX are defined for the apple (powerpc) platforms.
I would like to find one macro for the solaris platform, which will be different than a linux one.

Basically, I'd like to do that
#ifdef __THE_MACRO__
#  define __MY_APP_PLATFORM_1__
#elif defined(__ANOTHER_MACRO__)
#  define __MY_APP_PLATFORM_2__
#endif
etc...
(It's somehow my way to "detect" which platform I'm running on.
If anyone has a better suggestion, feel free to tell me :) )

Thanks

@ + Daz

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-10-02 13:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-01 22:19 which macro does gcc define beforehand ? lrtaylor
  -- strict thread matches above, loose matches on Subject: below --
2003-10-02 13:39 Martin York
2003-10-01 22:37 Daz
2003-10-01 22:14 Daz
2003-10-02  3:26 ` Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).