Variadic macro
A variadic macro is a function-like C preprocessor macro whose parameter list accepts a variable number of arguments through an ellipsis.
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
- Builds variable-length tracing interfaces that forward arguments, capture expressions, and supply calling context.
- How deep it goes
- Works through argument forwarding, empty-list handling, stringification, argument counting, and array conversion using helper macros.
- Examples
- Uses formatted trace calls, first-and-rest argument helpers, and a value-tracing interface backed by a temporary long double array.
- What you can do after
- Builds variadic macros from scratch for tracing, argument forwarding, and expression stringification.
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.
What to know first
- macroA macro is a named, reusable construct that expands into generated code or a sequence of commands when invoked, often during preprocessing, compilation, or application execution.
- variadic argumentsA variadic parameter is a function parameter form that allows a call to supply a variable number of arguments.
Related concepts
- __VA_ARGS__uses · __VA_ARGS__ is the predefined C preprocessor identifier that expands to arguments supplied for a variadic macro’s ellipsis parameter.
- variadic argumentsalternative to · A variadic parameter is a function parameter form that allows a call to supply a variable number of arguments.
- function-like macrokind of · A function-like macro is a macro invoked with function-like syntax that accepts token input and expands or transforms it into generated source.
- macrokind of · A macro is a named, reusable construct that expands into generated code or a sequence of commands when invoked, often during preprocessing, compilation, or application execution.
- __VA_OPT__uses · __VA_OPT__ is a C23 preprocessor feature that conditionally includes replacement tokens when a variadic macro receives one or more variable arguments.
Questions about variadic macro
What is variadic macro?
A variadic macro is a function-like C preprocessor macro whose parameter list accepts a variable number of arguments through an ellipsis.
Which Manning books explain variadic macro?
Modern C and Modern C, Third Edition.
What should I know before learning variadic macro?
Manning books that teach variadic macro usually introduce macro and variadic arguments first.
What is the difference between variadic macro and variadic arguments?
A variadic macro is a function-like C preprocessor macro whose parameter list accepts a variable number of arguments through an ellipsis. A variadic parameter is a function parameter form that allows a call to supply a variable number of arguments.
What is variadic macro a kind of?
Variadic macro is a kind of function-like macro. A function-like macro is a macro invoked with function-like syntax that accepts token input and expands or transforms it into generated source.
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.

