Stringification#
include/linux/stringify.h defines:
| |
Both use # to turn an argument into a string literal. They differ only when the argument is a macro.
# stringifies tokens before expanding any macros in them. So __stringify_1(x) gives you the literal text you passed, macro name included, unexpanded.
__stringify(x) adds one layer of indirection. Since x isn’t touched directly by # inside __stringify, the preprocessor expands x first when it’s passed down to __stringify_1, which then stringifies the expanded result.
Example:
| |
For a non-macro token: a variable name, a plain string, there’s nothing to expand, so both macros produce the same output.
Note: The indirection only work when the argument is a
#define.