liveBook · Manning

Variadic macro

A variadic macro is a function-like C preprocessor macro whose parameter list accepts a variable number of arguments through an ellipsis.

How 2 Manning books explain it

Modern C

A variadic macro is a C function-like macro whose parameter list accepts a variable number of arguments through an ellipsis.

How it is used
Uses variadic macros to build trace interfaces accepting a variable number of values.
How deep it goes
Works through argument forwarding, empty-list handling, stringification, counting, and array conversion; distinguishes these from variadic-function argument handling.
Examples
Builds tracing macros that print formatted values, accept messages without values, stringify expressions, and pass counted values through an array.
What you can do after
Build it from scratch: write a variadic trace macro and adapt it to handle calls with or without values.

Read how Modern C explains variadic macro →

Modern C, Third Edition

A variadic macro is a function-like C preprocessor macro that accepts a variable number of arguments through an ellipsis parameter.

How it is used
Uses variadic macros to build tracing and formatted-output interfaces with a variable number of arguments.
How deep it goes
Explains declaration syntax, expansion, empty-list handling, stringification, and token-pasting dispatch, while deferring complete implementation details.
Examples
Demonstrates TRACE_PRINT6, TRACE_PRINT8, formatted output, __VA_ARGS__ stringification, and fprintf dispatch macros.
What you can do after
Build it from scratch using ellipsis parameters, __VA_ARGS__, __VA_OPT__, stringification, and token pasting while avoiding empty-call errors.

Read how Modern C, Third Edition explains variadic macro →

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.