Reputation: 371
Let's say we have a macro defined as such
#define VALUE_ENTRY(a, b, c, d, e, f, g) \
case E_##a##e: temp.a##e = d; break;
How does the pre-processor know that the 'e' in 'temp' shouldn't be expanded? Is it due to not having ##
in front of the 'e'?
Also, should temp.a##e
be temp.##a##e
?
Upvotes: 4
Views: 63
Reputation: 61950
The preprocessor works on tokens. e
by itself is a token, whereas the e
in temp
is just a character that's part of the larger temp
token. ##
applies only to tokens.
Furthermore, pasting must produce a single token. Therefore, pasting .
and a
is not valid; temp.a##e
is correct, and pastes a
and e
to form temp.<a><e>
, where <a>
and <e>
are the replacement texts of a
and e
.
Upvotes: 6