Skip to content

Fixed-width integers (stdint.h)

Include stdint.h for fixed-width integer typedefs and limit macros that match the DCC C Compiler target model.

Types and macros

Name Meaning
int8_t Exact-width signed 8-bit integer type.
uint8_t Exact-width unsigned 8-bit integer type.
int16_t Exact-width signed 16-bit integer type.
uint16_t Exact-width unsigned 16-bit integer type.
int32_t Exact-width signed 32-bit integer type.
uint32_t Exact-width unsigned 32-bit integer type.
int_least8_t Smallest signed integer type with at least 8 bits.
uint_least8_t Smallest unsigned integer type with at least 8 bits.
int_least16_t Smallest signed integer type with at least 16 bits.
uint_least16_t Smallest unsigned integer type with at least 16 bits.
int_least32_t Smallest signed integer type with at least 32 bits.
uint_least32_t Smallest unsigned integer type with at least 32 bits.
int_fast8_t Signed integer type at least 8 bits wide that the Z80 operates on fastest (8-bit is native).
uint_fast8_t Unsigned integer type at least 8 bits wide that the Z80 operates on fastest (8-bit is native).
int_fast16_t Signed integer type at least 16 bits wide that the Z80 operates on fastest (16-bit is the natural word).
uint_fast16_t Unsigned integer type at least 16 bits wide that the Z80 operates on fastest (16-bit is the natural word).
int_fast32_t Signed integer type at least 32 bits wide that the Z80 operates on fastest (long is the widest integer).
uint_fast32_t Unsigned integer type at least 32 bits wide that the Z80 operates on fastest (long is the widest integer).
intptr_t Signed integer type capable of holding a pointer (16-bit target).
uintptr_t Unsigned integer type capable of holding a pointer (16-bit target).
intmax_t Maximum-width signed integer type supported by the runtime.
uintmax_t Maximum-width unsigned integer type supported by the runtime.
INT8_MIN Minimum value of int8_t.
INT8_MAX Maximum value of int8_t.
UINT8_MAX Maximum value of uint8_t (promotes to int).
INT16_MIN Minimum value of int16_t.
INT16_MAX Maximum value of int16_t.
UINT16_MAX Maximum value of uint16_t.
INT32_MIN Minimum value of int32_t.
INT32_MAX Maximum value of int32_t.
UINT32_MAX Maximum value of uint32_t.
INT_LEAST8_MIN Minimum value of int_least8_t.
INT_LEAST8_MAX Maximum value of int_least8_t.
UINT_LEAST8_MAX Maximum value of uint_least8_t.
INT_LEAST16_MIN Minimum value of int_least16_t.
INT_LEAST16_MAX Maximum value of int_least16_t.
UINT_LEAST16_MAX Maximum value of uint_least16_t.
INT_LEAST32_MIN Minimum value of int_least32_t.
INT_LEAST32_MAX Maximum value of int_least32_t.
UINT_LEAST32_MAX Maximum value of uint_least32_t.
INT_FAST8_MIN Minimum value of int_fast8_t.
INT_FAST8_MAX Maximum value of int_fast8_t.
UINT_FAST8_MAX Maximum value of uint_fast8_t.
INT_FAST16_MIN Minimum value of int_fast16_t.
INT_FAST16_MAX Maximum value of int_fast16_t.
UINT_FAST16_MAX Maximum value of uint_fast16_t.
INT_FAST32_MIN Minimum value of int_fast32_t.
INT_FAST32_MAX Maximum value of int_fast32_t.
UINT_FAST32_MAX Maximum value of uint_fast32_t.
INTPTR_MIN Minimum value of intptr_t.
INTPTR_MAX Maximum value of intptr_t.
UINTPTR_MAX Maximum value of uintptr_t.
INTMAX_MIN Minimum value of intmax_t.
INTMAX_MAX Maximum value of intmax_t.
UINTMAX_MAX Maximum value of uintmax_t.
PTRDIFF_MIN Minimum value of ptrdiff_t.
PTRDIFF_MAX Maximum value of ptrdiff_t.
SIZE_MAX Maximum value of size_t.
WCHAR_MIN Minimum value of wchar_t (unsigned on this target).
WCHAR_MAX Maximum value of wchar_t.
INT8_C Expand an integer constant to type int_least8_t.
INT16_C Expand an integer constant to type int_least16_t.
INT32_C Expand an integer constant to type int_least32_t.
UINT8_C Expand an integer constant to type uint_least8_t.
UINT16_C Expand an integer constant to type uint_least16_t.
UINT32_C Expand an integer constant to type uint_least32_t.
INTMAX_C Expand an integer constant to type intmax_t.
UINTMAX_C Expand an integer constant to type uintmax_t.
wchar_t Unsigned 16-bit wide character type.

Runtime model

The DCC C Compiler is a 16-bit target with 8-bit char, 16-bit int, and 32-bit long. stdint.h names the exact-width, least-width, fast-width, pointer-width, and maximum-width integer types that fit that runtime model without adding new runtime support. There are no 64-bit integer typedefs or limit macros.

The int_fastN_t / uint_fastN_t types are ordinary integer typedefs, not register-backed types. As in C99, "fast" means the type the target operates on fastest among those at least N bits wide: 8-bit maps to char (native on the Z80), 16-bit to int (the natural word), and 32-bit to long.

wchar_t is also defined here if no earlier header has defined it. The type is an unsigned 16-bit int, matching Common definitions.

Type selection

Use fixed-width names when the storage size is part of a file format, protocol, or packed structure:

#include <stdint.h>

struct rec {
    uint8_t  tag;
    uint16_t count;
    uint32_t checksum;
};

Use the ordinary C types when you only need the natural target word size.

For formatted output, use the underlying DCC C Compiler type. For example, uint32_t is an unsigned long, so print it with %lu or %lx. Literal formats select long support automatically; -fl / -flongio is only a blanket force-on override.