home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sgi / 13539 < prev    next >
Encoding:
Text File  |  1992-09-11  |  2.0 KB  |  51 lines

  1. Newsgroups: comp.sys.sgi
  2. Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!dhinds
  3. From: dhinds@leland.Stanford.EDU (David Hinds)
  4. Subject: Re: Bug in /usr/lib/cpp ?
  5. Message-ID: <1992Sep11.192707.25285@leland.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: DSG, Stanford University, CA 94305, USA
  8. References: <stefans.716210195@bauv106> <1992Sep11.183618.25338@odin.corp.sgi.com>
  9. Date: Fri, 11 Sep 92 19:27:07 GMT
  10. Lines: 39
  11.  
  12. In article <1992Sep11.183618.25338@odin.corp.sgi.com> ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz) writes:
  13. >In article <stefans.716210195@bauv106>, stefans@bauv106.bauv.unibw-muenchen.de (Stefan Schwarz) writes:
  14. >|> #define Concat(a,b) a/**/b
  15. >|> filename: /usr/lib/Concat(lib,X11.a)
  16. >|> 
  17. >|> cpp produces: filename: /usr/lib/ libX11.a
  18. >|>                                  ^extra space
  19. >|> I can't avoid this extra space!
  20. >|> 
  21. >|> acpp doesn't do this, but for several reasons i cannot switch to acpp.
  22. >
  23. >Changing /**/ to a space is a feature of acpp, not cpp.
  24.  
  25. The concatenation is not the issue here.
  26.  
  27.         #define X(a) a
  28.         filename: /usr/lib/X(libX11.a)
  29.  
  30.     produces with cpp:
  31.  
  32.         filename: /usr/lib/ libX11.a
  33.  
  34. The problem seems to be that with IRIX /usr/lib/cpp, macros that take
  35. arguments always introduce a leading space when they are expanded, but
  36. macros without arguments do not add the space.  This isn't normally a
  37. problem, because white space between tokens is not significant in C;
  38. this is a special case, because here the macro expansion is being done
  39. within something meant to later be a single token, sort of by tricking
  40. the preprocessor to treat the whole filename as several tokens for the
  41. purpose of macro expansion.  I'm not sure if this is supposed to be
  42. well-defined or not.
  43.  
  44. Anyway, the way to avoid the problem is to use acpp in '-traditional'
  45. mode, which seems to be a "better" K&R preprocessor than regular cpp.
  46. Compile with 'cc -Wp,-traditional' to get this.
  47.  
  48.         - David Hinds
  49.           dhinds@allegro.stanford.edu
  50.  
  51.