|
|
In pre-ANSI C compilers, there were at least two ways to combine two tokens. Both invocations in the following produced a single identifier x1 out of the two tokens x and 1.
#define self(a) a #define glue(a,b) a//b ++ self(x)1 glue(x,1)ANSI C could not sanction either approach to what they believed to be an important capability. In ANSI C, both the above invocations would produce the two separate tokens x and 1. The second of the above two methods can be rewritten for ANSI C by using the ## macro substitution operator:
#define glue(a,b) a ## b glue(x, 1)Since ## is an actual operator, the invocation can be much freer with respect to white space in both the definition and invocation.
There is no direct approach to effect the first of the two old-style pasting schemes, but since it put the burden of the pasting at the invocation, it was used less frequently than the other form.