...
The ##
preprocessing operator is used to merge two tokens into one while expanding macros. This , which is called token pasting or token concatenation. When a macro is expanded, the two tokens on either side of each ##
operator are combined into a single token , which that replaces the ##
and the two original tokens in the macro expansion [FSF 2005].
Token pasting is most useful when one or both of the tokens come from a macro argument. If either of the tokens next to an a ##
is a parameter name, it is replaced by its actual argument before ##
executes. The actual argument is not macro expanded first.
...
Parameters are not replaced inside string constants, but you can use the #
preprocessing operator can be used instead. When a macro parameter is used with a leading #
, the preprocessor replaces it with the literal text of the actual argument converted to a string constant [FSF 2005].
...
To stringify the result of expansion of a macro argument, you must use two levels of macros must be used:
Code Block | ||||
---|---|---|---|---|
| ||||
#define xstr(s) str(s) #define str(s) #s #define foo 4 |
...