home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11562 < prev    next >
Encoding:
Internet Message Format  |  1992-07-24  |  1.5 KB

  1. Path: sparky!uunet!think.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!ROUTH.KOSUFY.LU.SE!KOSU_MATSB
  2. From: KOSU_MATSB@ROUTH.KOSUFY.LU.SE
  3. Newsgroups: comp.lang.c
  4. Subject: Answer: Concatenation of macto values
  5. Message-ID: <1F03792480FF800A03@ursula.lucas.lu.se>
  6. Date: 24 Jul 92 15:04:19 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 31
  9. X-Unparsable-Date: Fri, 24 Jul 92 17:11 GMT+02
  10.  
  11. Hello!
  12.     Thanks for the answers!
  13.  
  14. To concatenate the VALUES of two macros the following works on
  15. GNU GCC 2.2.2:
  16.     #define Concat0(_x_,_y_) _x_ ## _y_
  17.     #define Concat(_p_,_q_) Concat0(_p_,_q_)
  18.  
  19.     #define A foo
  20.     #define B xyzzy
  21.     #define C Concat(A,B)
  22. The little cludge of Concat0 is needed to make the preprocessor 
  23. expand the macros BEFORE the ## operator is applied, ie
  24.     #define C Concat0(A,B)
  25. gives AB the value AB NOT fooxyzzy.
  26.  
  27. Thanks to:
  28. : f88ho@efd.lth.se (Hans Olsson)    (Who gave the exact solution).
  29.  
  30. and the following people giving hints:
  31. : briggs@progress.COM (Scott Briggs)
  32. : jos@and.nl (Jos Horsmeier)
  33. : tlg@uknet.ac.uk (Tim.Goodwin)
  34. : Mark Brader
  35.  -----------------------------------  -----------------------------------
  36.  Mats Bergstrvm                       mats.bergstrom@kosufy.lu.se
  37.  Div of Cosmic and Subatomic Physics  kosu_matsb@130.235.92.17
  38.  Department of Physics                ROUTH::KOSU_MATSB (ROUTH::=57412::)
  39.  University of Lund                   Phone: (+46)104767
  40.  SWEDEN.                              Fax:   (+46)104709
  41.  -----------------------------------  -----------------------------------
  42.