Stringizing Operator (#)

Syntax

# identifier

There may be any amount of white space before identifier, including none.

For a # sign to be recognised as a # operator, it must occur in the body of a macro that has a non-empty argument list. Otherwise, the # is just a #, and passes through the preprocessor without warning.

It is an error (C2162) if identifier is missing or is not among the macro’s formal arguments.

Behaviour

The # operator acts within a macro body to direct that should the macro ever be expanded, the formal argument named by identifier is to be replaced not exactly by the corresponding actual argument but by this argument in a string-ised form. This means, briefly, that the argument becomes enclosed by double quotes. The operator itself, along with any white space that follows, does not pass into the expansion.