home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20292 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.4 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!emory!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!sics.se!eua.ericsson.se!ericom!terminus.ericsson.se!!rejkjavik!srl
  2. From: srl@terminus.ericsson.se (Steve Langstaff)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Preprocessor question
  5. Message-ID: <1099@quirm.terminus.ericsson.se>
  6. Date: 27 Jan 93 09:48:00 GMT
  7. References: <1k44lqINNjr3@rs2.hrz.th-darmstadt.de>
  8. Sender: usenet@terminus.ericsson.se
  9. Reply-To: srl@terminus.ericsson.se
  10. Distribution: world
  11. Organization: Camtec Electronics (Ericsson), Leicester, England
  12. Lines: 24
  13. Nntp-Posting-Host: rejkjavik
  14.  
  15. In article 1k44lqINNjr3@rs2.hrz.th-darmstadt.de, misar@rbg.informatik.th-darmstadt.de (Walter Misar) writes:
  16. : In article <mick.728072797@picus>, mick@dcs.bbk.ac.uk (Mick Farmer) writes:
  17. : > Hi,
  18. : > 
  19. : > Karim asks how to get a preprocessor macro recognised inside
  20. : > a string.  The answer, at least in ANSI C, is to use the
  21. : > stringising operator and string concatenation:
  22. : > 
  23. : > #define JUNK 50
  24. : > static char *junk = #JUNK " ways to leave your lover"
  25. :                       ^^^^^
  26. : Nope, #token works only with #defines like in:
  27. : #define stringify(x) #x
  28. : #define str_exp(x) stringify(x)        /* this extra level IS necessary */
  29. : static char *junk = str_exp(JUNK) "ways ....";
  30. [snip]
  31.  
  32. Why is the extra level necessary?
  33.  
  34. ---
  35.  
  36. |  Steve Langstaff - Ericsson CAMTEC | 
  37.  
  38.