Preprocessor
Stringizing Macro
The # operator turns a macro argument into a string literal.
Stringizing Macro
stringizing_macro.c
#include <stdio.h>
#define LABEL(name) #name
int main(void) {
int value = ;
const char *name = "value";
printf("%s=%d\n", name, value);
return 0;
}
#include <stdio.h>
#define LABEL(name) #name
int main(void) {
int value = ;
const char *name = "value";
printf("%s=%d\n", name, value);
return 0;
}
#include <stdio.h>
#define LABEL(name) #name
int main(void) {
int value = ;
const char *name = "value";
printf("%s=%d\n", name, value);
return 0;
}
stringizing
Inside a macro replacement, `#argument` produces the source text of that argument.
labels
Stringizing is useful for labels in diagnostics and small reports.
expanded string
The string literal in the trace is what the macro would produce before compilation.