liveBook · Manning

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.

How 2 Manning books explain it

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.

Read how Modern C explains type-generic 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.