home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sun4nl!and!jos
- From: jos@and.nl (Jos Horsmeier)
- Newsgroups: comp.lang.c
- Subject: Re: Concatenation of two macros?
- Message-ID: <3159@dozo.and.nl>
- Date: 23 Jul 92 15:58:11 GMT
- References: <1FE7B81211DF800725@ursula.lucas.lu.se>
- Organization: AND Software BV Rotterdam
- Lines: 32
-
- In article <1FE7B81211DF800725@ursula.lucas.lu.se> KOSU_MATSB@ROUTH.KOSUFY.LU.SE writes:
- |
- | Concatenation of two macros. Is it possible?
- |
- | If i have the following two definitions:
- | #define A pre
- | #define B post
- | And want to "#define C" to be "prepost" BUT as an
- | expression of A and B! How do i do it?
- | #define C (expression of A and B to yield prepost)
-
- Most pre-ANSI C preprocessors allow you to do the following trick:
-
- #define C(A, B) A/**/B
-
- A conformant ANSI-C preprocessor inserts at least one white space
- character when replacing the empty comment in the replacement list,
- but they came up with the following (what I call `ugly') construct:
-
- #define C(A, B) A ## B
-
- The `##' operator `glues' the two operands together and the resulting
- preprocessing token is available for replacement in the rescan phase
- of the macro expansion.
-
- kind regards,
-
- Jos aka jos@and.nl
-
- ps. I just call this thingy `ugly', because it doesnt' `look good'
- to me. The same counts for the trigraph characters. Yuck!
- Maybe I'm just too old ... dunno ... ;-)
-