liveBook · Manning

Stringification operator

The stringification operator is the C preprocessor operator # that converts a macro argument's textual spelling into a string literal.

How 2 Manning books explain it

Modern C, Third Edition

Macro argument stringification is the C preprocessing technique of converting a macro argument's textual spelling into a string literal.

How it is used
Supports compile-time diagnostic and tracing macros by preserving the caller's expression spelling.
How deep it goes
Explains textual conversion, suppressed argument expansion, and the two-layer workaround, but stops short of preprocessing implementation internals.
Examples
Uses STRINGIFY, STRGY, TRACE_PRINT5, __LINE__, expressions, and variadic arguments as concrete examples.
What you can do after
Apply it via C macros to emit expression text and safely stringify values such as expanded line numbers.

Read how Modern C, Third Edition explains stringification operator →

Modern C

Stringification is the preprocessing technique of converting a macro argument's tokens into a string literal.

How it is used
Supports debugging macros by recording source expressions, line numbers, function names, and variadic argument text in trace output.
How deep it goes
Explains textual replacement, nonexpansion, and two-level indirection through trace macros, while deferring broader preprocessing details.
Examples
Uses TRACE_PRINT5 and TRACE_PRINT9 to label sum, sum*argc, line numbers, and variadic expressions in diagnostic output.
What you can do after
Apply it via C preprocessing to build trace macros that print source expressions and expanded line numbers alongside evaluated values.

Read how Modern C explains stringification operator →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.