OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
Fixed-Width Types

Integer types with guaranteed sizes. More...

Typedefs

typedef signed short s16
 16-bit signed integer (-32768 to 32767)
typedef signed int s32
 32-bit signed integer (-2147483648 to 2147483647)
typedef signed char s8
 8-bit signed integer (-128 to 127)
typedef unsigned short u16
 16-bit unsigned integer (0 to 65535)
typedef unsigned int u32
 32-bit unsigned integer (0 to 4294967295)
typedef unsigned char u8
 8-bit unsigned integer (0 to 255)

Detailed Description

Integer types with guaranteed sizes.

On the 65816 CPU (cproc compiler), since chantier A1 (2026-05-08):

  • char = 8 bits
  • short = 16 bits
  • int = 16 bits (2 bytes)
  • long = 32 bits (4 bytes) (see compiler/cproc/type.c — typeint size 2, typelong size 4.)

Always use these typedefs instead of C primitive types.

Typedef Documentation

◆ s16

typedef signed short s16

16-bit signed integer (-32768 to 32767)

◆ s32

typedef signed int s32

32-bit signed integer (-2147483648 to 2147483647)

Conditionally typedef'd to maintain sizeof(s32) == 4 on the two compilers that touch this header:

  • cc65816 (cproc + QBE w65816 — the actual SDK compiler): long is 4 bytes since chantier A1 (2026-05-08). Pre-A1 used int for the 32-bit type because cproc treated int as 32-bit; A1 made int 2 bytes, so the canonical 32-bit type moves to long. The bin/cc65816 wrapper passes -D__OPENSNES__=1 to its preprocessor so this branch fires.
  • Host clang (the -fsyntax-only parallel lint pass in make/common.mk): on x86_64 / arm64, int is 4 bytes and long is 8. To keep sizeof(s32) == 4 on the lint side, we fall back to int here (the #else branch). The lint does NOT receive -D__OPENSNES__.

The underlying typedef differs per compiler, but sizeof(s32) == 4 holds in both — which is the property the SDK's static asserts and data layout rely on.

◆ s8

typedef signed char s8

8-bit signed integer (-128 to 127)

◆ u16

typedef unsigned short u16

16-bit unsigned integer (0 to 65535)

◆ u32

typedef unsigned int u32

32-bit unsigned integer (0 to 4294967295)

See s32 for the cc65816-vs-host-lint conditional rationale.

◆ u8

typedef unsigned char u8

8-bit unsigned integer (0 to 255)