Luce Base
LuceEngineeringLuciaOS

22. C to Base

int *p = &x;                 let p: i32* = &x
const T *p                   p: const T*
T *const *pp                 pp: const (T*)*
volatile uint32_t *reg       reg: volatile u32*
void *ctx                    ctx: void*
p->f                         p.f
*p = v                       *p = v
(T *)q                       (T*)q
(uint8_t)x                   (u8)x           # u8(x) is the checked form
(int)f                       (i32)f          # saturating; i32(f) traps
NULL / if (p)                none / if let q = p:
sizeof(T), offsetof(T, f)    sizeof(T), offsetof(T, f)
T a[N]                       var a: T[N]
char buf[N] = {0};           var buf: u8[N]
char buf[N];                 var buf: u8[N] = ---
T *items, size_t count       items: T[]
char *s                      s: cstr
a / b (ints)                 a // b          # floor; truncating_div for C's
x * 31 + c (wrapping)        x *% 31 +% c
a && b, !a                   a and b, not a
goto cleanup                 defer / errdefer
break out of nested loop     outer: for ... / break outer
int f(T *out)                func f() -> (bool, T)
switch                       match, `1, 2, 3:` alternatives, ranges
static int helper()          func helper()   # private by default
static int counter; (local)  var counter: i32   # module level
_Thread_local int t;         thread_local var t: i32
#include "x.h"               import x
#ifdef __x86_64__            asm x86_64: ... / per-target modules
printf("%d\n", n)            print(f"{n}")
_Atomic int n; n++;          var n: @i32; n +%= 1     # n += 1 checks
union { int i; float f; }    union Value: / integer: i32 / real: f32
__attribute__((noreturn))    -> never