cbase 1.50.0
C/C++ Static Template
Loading...
Searching...
No Matches
base_types.h File Reference

Core fixed-width type aliases and memory size constants. More...

#include <float.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for base_types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KB(x)
#define MB(x)
#define GB(x)
#define TB(x)

Typedefs

typedef uint8_t u8
typedef uint16_t u16
typedef uint32_t u32
typedef uint64_t u64
typedef int8_t s8
typedef int16_t s16
typedef int32_t s32
typedef int64_t s64
typedef int8_t i8
typedef int16_t i16
typedef int32_t i32
typedef int64_t i64
typedef size_t usize
typedef ptrdiff_t isize
 Signed size type pointer-width, matches ptrdiff_t.
typedef uintptr_t uptr
typedef intptr_t iptr
typedef float f32
typedef double f64
typedef uint8_t byte
typedef bool b8
typedef int32_t b32

Detailed Description

Core fixed-width type aliases and memory size constants.

Provides short, consistent type names across the entire codebase so that integer widths are always explicit. Replaces the verbose stdint.h names (uint32_t, int64_t, etc.) with concise aliases (u32, i64, etc.) that are faster to read and write without sacrificing precision.

Type Naming Convention
  • u prefix = unsigned integer (u8, u16, u32, u64)
  • s prefix = signed integer, explicit sign (s8, s16, s32, s64)
  • i prefix = signed integer, alternate alias (i8, i16, i32, i64)
  • f prefix = floating-point (f32, f64)
  • b prefix = boolean (b8, b32)
  • usize = unsigned pointer-width size (equivalent to size_t)
  • isize = signed pointer-width size (equivalent to ptrdiff_t)
Why Both s and i Aliases?
Some codebases prefer s32 (signed 32-bit) while others use i32 (integer 32-bit). Both are provided so you can pick a convention and stay consistent. They expand to exactly the same underlying type.
Boolean Types
b32 (int32_t) is preferred over b8 (bool) for general use because 32-bit booleans avoid implicit sign-extension bugs and are typically faster to operate on than sub-word types on modern 32/64-bit CPUs. Use b8 when packing booleans into structs where size matters.

Definition in file base_types.h.