Type-generic macro
A type-generic macro is a macro-based interface whose expansion selects or adapts operations according to the types of its arguments or associated objects.
Modern C, Third Edition
A type-generic statement is a statement-form macro expansion whose operations can adapt to the types of its arguments or associated objects.
- How it is used
- Groups type-adaptable operations into a statement usable where a void function call would fit.
- How deep it goes
- Works through a locking macro’s wrapper, typed local variables, single argument evaluation, and loop, while acknowledging maintenance costs.
- Examples
- Uses a dataCondStore macro with typed temporaries, mutex locking, comparison, conditional assignment, and an outer do ... while(false).
- What you can do after
- Build it from scratch using a do ... while(false) wrapper and typed temporaries that evaluate macro arguments at most once.
Read how Modern C, Third Edition explains type-generic macro →
Modern C
A type-generic macro interface is a macro-based C interface that selects type-specific operations for its arguments.
- How it is used
- Deploys one interface for mathematical or user-defined operations while dispatching to type-specific functions.
- How deep it goes
- Explains _Generic syntax, function-pointer dispatch, arithmetic promotions, and two-argument selection, but defers exhaustive macro coverage.
- Examples
- Uses fabs dispatch, a floating-point minimum macro, maximum-value macros, and type-generic tracing conversions.
- What you can do after
- Builds type-generic C interfaces by combining _Generic selections with macros and type-specific functions.
Related concepts
- _Genericuses · _Generic is a C11 primary expression that selects one expression from type-associated alternatives according to the type of a controlling expression.
- tgmath.hpart of · tgmath.h is the C standard header providing type-generic macros that select mathematical functions according to argument types.
- cosine functionalternative to · The cosine function is a periodic trigonometric function that maps a real number or angle to a value between −1 and 1.
- pure functionuses · A pure function is a function whose output is determined solely by its explicit inputs and whose evaluation has no externally observable side effects.
- functionuses · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
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.

