Skip to content

Instantly share code, notes, and snippets.

View definitepotato's full-sized avatar
🤓

definitepotato definitepotato

🤓
View GitHub Profile
@TheSantacloud
TheSantacloud / zig-0.13.0-builtins.csv
Created August 16, 2024 17:05
Zig built-ins cheatsheet 0.13.0
@addrSpaceCast(ptr: anytype) anytype Pointer conversion to another address space
@addWithOverflow(a: anytype, b: anytype) struct { @TypeOf(a, b), u1 } Addition with overflow detection
@alignCast(ptr: anytype) anytype Pointer alignment
@alignOf(comptime T: type) comptime_int Alignment for the current target in bytes
@as(comptime T: type, expression) T Safe type coercion
@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: AtomicOrder) T Atomic dereference of pointer
@atomicRmw(comptime T: type, ptr: *T, comptime op: AtomicRmwOp, operand: T, comptime ordering: AtomicOrder) T Atomic modify and return previous value
@atomicStore(comptime T: type, ptr: *T, value: T, comptime ordering: AtomicOrder) void Atomic store of value at address
@bitCast(value: anytype) anytype Type cast at compile time
@bitOffsetOf(comptime T: type, comptime field_name: []const u8) comptime_int Bit offset of field within struct
@ityonemo
ityonemo / test.md
Last active October 23, 2025 01:27
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)