Type-generic interface
A type-generic interface is a programming interface that selects or adapts operations according to the types of its arguments or associated values.
Modern C, Third Edition
Type-generic programming is a programming technique that selects or adapts operations according to the types of values involved.
- How it is used
- Presents one callable interface for operations whose selected function or result type depends on argument types.
- How deep it goes
- Explains macro and _Generic selection with examples, including fixed-type limits and qualification safety; does not detail atomic-interface implementations.
- Examples
- Uses cos and fabs function families, a two-argument minimum macro, and const-qualified strstr calls.
- What you can do after
- Build it from scratch with a _Generic macro that selects functions for a specified set of argument types.
Read how Modern C, Third Edition explains type-generic interface →
Modern C
Type-generic programming is a technique for providing one interface that selects or adapts behavior according to the types of its inputs.
- How it is used
- Deploys macros with _Generic to present one type-safe interface over several type-specific functions or values.
- How deep it goes
- Explains _Generic selection and multi-argument dispatch, then demonstrates practical macro utilities without developing every language corner case.
- Examples
- Uses fabs dispatch, floating-point minimum, maximum-value selection, and tracing formats and conversions as concrete implementations.
- What you can do after
- Builds type-generic C11 macro interfaces that dispatch to typed functions or expressions while avoiding unnecessary macro evaluation hazards.
Related concepts
- _Genericimplemented by · _Generic is a C11 primary expression that selects one expression from type-associated alternatives according to the type of a controlling expression.
- atomic typecontrasts with · An atomic type is a type whose supported accesses and operations are indivisible with respect to concurrent execution and provide defined synchronization semantics.
- tgmath.huses · tgmath.h is the C standard header providing type-generic macros that select mathematical functions according to argument types.
- type-generic macrohas part · 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.
- function-like macroimplements · 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.

