Question with cpp and token pasting
Christopher R Volpe
volpe at camelback.crd.ge.com
Fri Feb 1 03:39:09 AEST 1991
In article <1991Jan30.232740.1697267 at locus.com>, bringo at locus.com (Bob
Ringo) writes:
|>Hi, this is probably a simple task, but I haven't figured it out.
|>I'd like to do the following:
|>
|>#define A "Good"
|>#define B "Morning"
|>#define C /* the concatenation of A and B */
|>
|>
|>--I tried the following, but it didn't work.
|>
|>#define paste(x,y) x ## y
|>#define A "Good"
|>#deifne B "Morning"
|>#define C paste(A,B)
Is there any reason you can't rely on the compiler's automatic concatenation
of adjacent string literals? For example,
printf(A B);
will print "GoodMorning".
|>Bob Ringo
|>Locus Computing Corporation
|>bringo at locus.com
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com
More information about the Comp.lang.c
mailing list