...
JOIN(x, y)
calls JOIN_AGAIN(x, y)
so that, if x
or y
is a macro, they are it is expanded before the ##
operator pastes them together.
...
The macro invocation str(foo)
expands to "foo"
.
Compliant Solution
To stringify the result of expansion of a macro argument, you must use two levels of macros:
...
The macro invocation xstr(foo)
expands to "4"
. This is because 's'
is stringified when it is used in str()
, so it is not macro expanded first. However, 's'
is an ordinary argument to xstr()
, so it is completely macro expanded before xstr()
is expanded. Consequently, by the time str()
gets to its argument, it has already been macro expanded.
...