home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!gatech!destroyer!gumby!wupost!decwrl!csus.edu!netcomsv!delfin.com!hades!kinne
- From: kinne@delfin.com (Kinne Strong)
- Subject: Re: C++ compiler macros
- Message-ID: <1992Jul22.185457.21999@delfin.com>
- Sender: news@delfin.com (USENET on Delfin)
- Nntp-Posting-Host: hades
- Organization: Foxglove Associates
- X-Newsreader: Tin 1.1 PL4
- References: <1992Jul21.001718.8580@taumet.com>
- Distribution: usa
- Date: Wed, 22 Jul 1992 18:54:57 GMT
- Lines: 29
-
- steve@taumet.com (Steve Clamage) writes:
- :
- : You could do this:
- :
- : #if defined(__cplusplus)
- : ... C++ compiler
- : #elif __STDC__ == 1
- : ... Standard C compiler
- : #elif defined(__STDC__)
- : ... you probably have function prototypes
- : ... no telling what else you can count on
- : #else
- : ... K&R
- : #endif
- :
- : Of course, not all pre-Standard compilers recognize #elif. Sigh.
-
- I wouldn't want to bet on the test of __STDC__ not generating an error
- when __STDC__ was not defined, either, although it worked just fine on
- Sun C++ when I tried it. Sun C++ seems to treat undefined symbols as
- having a value of 0 -- something I can find no justification for (though
- I haven't tried very hard). Anyone know if this can be relied on?
-
- If you must worry about very very old compilers you will need to use
- #ifdef instead of #if defined() (and you have my sympathy).
-
- --
- Kinne Strong
- kinne@netcom.com
-