home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!ROUTH.KOSUFY.LU.SE!KOSU_MATSB
- From: KOSU_MATSB@ROUTH.KOSUFY.LU.SE
- Newsgroups: comp.lang.c
- Subject: Answer: Concatenation of macto values
- Message-ID: <1F03792480FF800A03@ursula.lucas.lu.se>
- Date: 24 Jul 92 15:04:19 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Lines: 31
- X-Unparsable-Date: Fri, 24 Jul 92 17:11 GMT+02
-
- Hello!
- Thanks for the answers!
-
- To concatenate the VALUES of two macros the following works on
- GNU GCC 2.2.2:
- #define Concat0(_x_,_y_) _x_ ## _y_
- #define Concat(_p_,_q_) Concat0(_p_,_q_)
-
- #define A foo
- #define B xyzzy
- #define C Concat(A,B)
- The little cludge of Concat0 is needed to make the preprocessor
- expand the macros BEFORE the ## operator is applied, ie
- #define C Concat0(A,B)
- gives AB the value AB NOT fooxyzzy.
-
- Thanks to:
- : f88ho@efd.lth.se (Hans Olsson) (Who gave the exact solution).
-
- and the following people giving hints:
- : briggs@progress.COM (Scott Briggs)
- : jos@and.nl (Jos Horsmeier)
- : tlg@uknet.ac.uk (Tim.Goodwin)
- : Mark Brader
- ----------------------------------- -----------------------------------
- Mats Bergstrvm mats.bergstrom@kosufy.lu.se
- Div of Cosmic and Subatomic Physics kosu_matsb@130.235.92.17
- Department of Physics ROUTH::KOSU_MATSB (ROUTH::=57412::)
- University of Lund Phone: (+46)104767
- SWEDEN. Fax: (+46)104709
- ----------------------------------- -----------------------------------
-