liveBook · Manning

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.

How 2 Manning books explain it

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.

Read how Modern C explains type-generic interface →

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.