Types

Contents

Types#

C’s type system is small and concrete. Fixed-width arithmetic types, pointers (typed), arrays (with implicit decay to a pointer), structs and unions (no methods), enums (named integers), and function types. The compiler does not infer; the operator writes every type explicitly.

For literals, see Syntax. For operators, see Operators.

Pages#

Primitives

char, int family, float / double, bool, void.

Primitives
Fixed widths

<stdint.h>: int8_t..``int64_t``, size_t, intptr_t, ptrdiff_t.

Fixed widths
Strings

Null-terminated char arrays; safe APIs.

Strings
Arrays

Fixed size; decay to pointer; VLA caveats.

Arrays
Pointers

Typed addresses; pointer arithmetic; const placement.

Pointers
Structs

Records; designated initialisers; opaque types.

Structs
Unions

Overlaid fields; tag-and-union pattern.

Unions
Enums

Named integer constants.

Enums
Function types

Function-pointer types; typedef for callbacks.

Function types
Casting

(T)expr; integer promotion; usual arithmetic conversions.

Casting

References#