zig-0.16
SKILL.md
Zig 0.16-dev Porting Notes
This skill captures gotchas hit when porting a 0.15 project to Zig 0.16-dev (std.Io world). APIs keep moving; always check the stdlib sources for your exact build.
Std.Io replaces std.net / legacy std.posix wrappers
std.netis gone. The new networking lives understd.Io.net(types:IpAddress,Stream,Server,UnixAddress, etc.).- High-level functions like
tcpConnectToHost,Address.parseIp,Stream.connect,Stream.read/writeAllno longer exist. You must useIovtables (io.vtable.netConnectIp,netRead,netWrite,netListenIp,netAccept). - If you need raw fds, call platform syscalls (
std.os.linux.socket,accept4,connect,bind,listen,write,writev,read,close). Many helpers that were understd.posixare gone. posix.socket,posix.bind,posix.accept,posix.shutdown,posix.writev,posix.listen,posix.pipe2,posix.getrandom,std.net.has_unix_sockets, etc. are removed. Usestd.os.<platform>syscalls andposix.system.*where available, or the Io vtable.- Epoll: use
std.os.linux.epoll_create1/epoll_ctl/epoll_waitdirectly; signatures include an explicitcountparam for writev/epoll_wait.
Std.Io Readers/Writers
- New writer/reader interfaces live under
std.Io. TLS expects*std.Io.Reader/*std.Io.Writer(struct fields.interface). Pass pointers to interfaces, not callinterface()as a function. std.time.sleepremoved; usestd.Io.sleep(io, Duration, Clock).
Time / Random / Env / Exit
std.time.milliTimestampremoved. Usestd.time.Timerorstd.Io.Clock.now(clock, io)and compareTimestamp.nanoseconds.- Random secure bytes:
std.Io.randomSecure(io, buf); nostd.crypto.randomorstd.posix.getrandomconvenience. std.process.getEnvVarOwnedis gone; usestd.c.getenvand copy.std.posix.exitremoved; usestd.process.exit.
TLS Client options
std.crypto.tls.Client.Optionsnow requiresentropy: *const [entropy_len]u8andrealtime_now_seconds: i64. Fill entropy withstd.Io.randomSecure; compute seconds withIo.Clock.now(.real, io)/ns_per_s.
MemoryPool API changes
std.heap.MemoryPool(T).initCapacity(allocator, n)returns the pool;create/destroynow require allocator. No bareinit()or zero-argdeinit().
Atomic order & Thread
- Atomic orders use
.monotonic/.seq_cst;.awakeremoved.
Format options
std.fmt.OptionsreplacesFormatOptions.std.fmt.formathelper is gone; callwriter.printdirectly (writers live instd.Io.Writer).
Randomness / crypto changes
std.crypto.randomwas removed. Use anstd.Ioinstance:const io = std.Io.Threaded.global_single_threaded.ioBasic(); io.random(&buf);.Ed25519.KeyPair.generatenow requires anio: std.Ioargument:Ed25519.KeyPair.generate(io);.
Enum conversion
std.meta.intToEnumremoved. Usestd.enums.fromInt(EnumType, value)(returns?EnumType).
Fixed-buffer writers in tests
std.io.fixedBufferStreamwas removed. For in-memory writes usevar w = std.Io.Writer.fixed(buf);and read bytes withstd.Io.Writer.buffered(&w).std.ArrayListno longer has.init(allocator)shorthand; use.initBuffer(slice)for stack buffers or managed variants.
Stream/Conn helpers we added (compat pattern)
- Build a thin compat layer that wraps platform syscalls to reintroduce
Stream { read, writeAll, close, readAtLeast }and address parsing/formatting, plustcpConnectToHost/Addressusing raw sockets. - For Unix sockets: build sockaddr manually and call
connect.
Testing adjustments
- For in-process client/server tests, use
socketpair(AF.UNIX, SOCK.STREAM|CLOEXEC, 0, &fds)to avoid relying on Io vtable network (Threaded nets returnNetworkDownif not wired).
Error sets tightened
- Many functions return narrower error sets (e.g., Reader.fill no longer includes
WouldBlock/Timeout). Remove unreachable branches accordingly.
syscalls return types
std.os.linux.*returnusize; cast with@as(isize, @bitCast(rc))before checking< 0. Forwritev/epoll_waitinclude thecountargument.
Use this skill when upgrading 0.15-era code to 0.16-dev to avoid common build-breakers.
Weekly Installs
5
Repository
zigcc/skillsGitHub Stars
5
First Seen
Feb 1, 2026
Installed on
opencode4
claude-code4
gemini-cli3
github-copilot3
amp3
codex3