I read the following code:
#define MACRO(abc, def) {#def ## #abc}
char result[10] = MARCO(abc, def);
I know the ##
operator is used to merge the two string to one, but what about the #
in front of def
and abc
?
From the standard (emphasis mine):
16.3.2 The # operator [cpp.stringize]
2/ A character string literal is a string-literal with no prefix. If, in the replacement list, a parameter is immediately preceded by a # preprocessing token, both are replaced by a single character string literal preprocessing token that contains the spelling of the preprocessing token sequence for the corresponding argument. [...]
It "stringifies" the token following the #
.
Example:
#define STRINGIFY(x) #x
STRINGIFY(foo) // will be replaced by "foo"