home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11343 < prev    next >
Encoding:
Text File  |  1992-07-22  |  1.3 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!gatech!destroyer!gumby!wupost!decwrl!csus.edu!netcomsv!delfin.com!hades!kinne
  3. From: kinne@delfin.com (Kinne Strong)
  4. Subject: Re: C++ compiler macros
  5. Message-ID: <1992Jul22.185457.21999@delfin.com>
  6. Sender: news@delfin.com (USENET on Delfin)
  7. Nntp-Posting-Host: hades
  8. Organization: Foxglove Associates
  9. X-Newsreader: Tin 1.1 PL4
  10. References: <1992Jul21.001718.8580@taumet.com>
  11. Distribution: usa
  12. Date: Wed, 22 Jul 1992 18:54:57 GMT
  13. Lines: 29
  14.  
  15. steve@taumet.com (Steve Clamage) writes:
  16. : You could do this:
  17. : #if defined(__cplusplus)
  18. :     ... C++ compiler
  19. : #elif __STDC__ == 1
  20. :     ... Standard C compiler
  21. : #elif defined(__STDC__)
  22. :     ... you probably have function prototypes
  23. :     ... no telling what else you can count on
  24. : #else
  25. :     ... K&R
  26. : #endif
  27. : Of course, not all pre-Standard compilers recognize #elif.  Sigh.
  28.  
  29. I wouldn't want to bet on the test of __STDC__ not generating an error
  30. when __STDC__ was not defined, either, although it worked just fine on
  31. Sun C++ when I tried it. Sun C++ seems to treat undefined symbols as
  32. having a value of 0 -- something I can find no justification for (though
  33. I haven't tried very hard). Anyone know if this can be relied on?
  34.  
  35. If you must worry about very very old compilers you will need to use
  36. #ifdef instead of #if defined() (and you have my sympathy).
  37.  
  38. --
  39. Kinne Strong
  40. kinne@netcom.com
  41.