The # operator turns a macro argument into a string literal.

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.

Stringizing Macro

value
stringizing_macro.c
Replay: real traced execution (multi-file project)
#include <stdio.h>

#define LABEL(name) #name

int main(void) {
    int value = 3;
    const char *name = "value";

    printf("%s=%d\n", name, value);
    return 0;
}
#include <stdio.h>

#define LABEL(name) #name

int main(void) {
    int value = 5;
    const char *name = "value";

    printf("%s=%d\n", name, value);
    return 0;
}
#include <stdio.h>

#define LABEL(name) #name

int main(void) {
    int value = 8;
    const char *name = "value";

    printf("%s=%d\n", name, value);
    return 0;
}
  1. value ← 3, name ← value

    5int main(void) {6    int value→ 3 = 3; //@value=5, 87    const char *name→ value = "value";89    printf("%s=%d\n", namevalue, value3);10    return 0;11}
    outputvalue=3
  1. value ← 5, name ← value

    5int main(void) {6    int value→ 5 = 5;7    const char *name→ value = "value";89    printf("%s=%d\n", namevalue, value5);10    return 0;11}
    outputvalue=5
  1. value ← 8, name ← value

    5int main(void) {6    int value→ 8 = 8;7    const char *name→ value = "value";89    printf("%s=%d\n", namevalue, value8);10    return 0;11}
    outputvalue=8