home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / sgi / bugs / 35 < prev    next >
Encoding:
Text File  |  1992-12-23  |  2.2 KB  |  59 lines

  1. Newsgroups: comp.sys.sgi.bugs
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!sdd.hp.com!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!rbutterw
  3. From: "Ray Butterworth [MFCF]" <rbutterw@math.uwaterloo.ca>
  4. Subject: Recognizing which cc is being used.
  5. Message-ID: <BzqCEy.HG9@math.uwaterloo.ca>
  6. Sender: rbutterw@math.uwaterloo.ca (Ray Butterworth [MFCF])
  7. Organization: Math Faculty Computing Facility, University of Waterloo
  8. Date: Wed, 23 Dec 1992 20:47:22 GMT
  9. Lines: 48
  10.  
  11. The cc(1) on IRIX 4.0.5f seems to operate in 3 different modes:
  12. -cckr, -ansi, and -xansi.
  13.  
  14. -ansi  defines __STDC__
  15. -xansi doesn't, but does define __EXTENSIONS__
  16. -cckr also doesn't define __STDC__, and it also defines __EXTENSIONS__.
  17.  
  18. How is one supposed to test (in the source) which of the
  19. last two modes the compiler is running under?
  20. (I suggest that -cckr should set some symbol to indicate this.)
  21.  
  22. In particular, does one use  token/**/token  or  token##token
  23. to join two cpp tokens in a macro?
  24.  
  25.  
  26. I checked various stock header files for examples of how
  27. it is supposed to be done, but with no luck.
  28.  
  29. The header file <sys/termio.h> contains:
  30.    #define CTRL(c) ('c'&037)
  31. which only works with -cckr, so this header file is in fact broken
  32. since it needs a test for what kind of cpp is being used too.
  33.  
  34. And the header file <gl/dgl.h> has code like this:
  35.    #ifdef __STDC__
  36.    #define SIZEOF(x) size_##x
  37.    #else
  38.    #define SIZEOF(x) size_/**/x
  39.    #endif /*__STDC__*/
  40.  
  41. But this particular section never gets looked at on IRIX,
  42. so it doesn't matter that it doesn't work.
  43.  
  44.  
  45. But I have my own header files that need to do something similar, 
  46. and I can't find any #if test that will determine which form of
  47. token joining should be used.
  48.  
  49. Note that suggestions of the form "put -D__ANSI__" on the command
  50. line are of no help to me.  These header files must be used by
  51. different people and Makefiles that might be calling different
  52. versions of cc.  I can't expect everyone to change what they
  53. are doing; in fact one of the purposes of the header files is
  54. that they won't have to.  i.e. the solution has to be done
  55. entirely within my header file(s).
  56.  
  57. (Please email any responses, since your article will probably
  58.  expire over the holidays before I get a chance to read it.)
  59.