C Programming • C17 baseline, standards-specific features labeled
typedef and Readable Type Names
Use typedef to give complex or domain-specific types a clearer name without hiding their behavior.
typedef introduces an alias for an existing type; it does not create a distinct type or runtime conversion. Aliases are useful for public API names and callback signatures, but overusing them can hide pointers or make types harder to inspect.
Example
#include <stddef.h>
typedef struct {
double x;
double y;
} Point;
typedef int (*CompareInts)(const void *, const void *);
size_t point_count(const Point points[], size_t count);
What to expect
Point is an alias for the anonymous structure type; CompareInts names a specific callback pointer type.
Key idea: Use aliases to improve an interface, not to obscure ownership, pointer indirection, or representation.