about things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add O_NONBLOCK cross-platform pattern to 0.16 migration notes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+15
+15
languages/ziglang/0.16/migration.md
··· 219 219 const q: i32 = std.math.cast(i32, q_raw) orelse return error.EpollError; 220 220 ``` 221 221 222 + ### O_NONBLOCK cross-platform 223 + 224 + never hardcode `O_NONBLOCK` — it differs per platform (macOS `0x0004`, Linux `0o4000`). use zig's typed packed struct: 225 + 226 + ```zig 227 + const libc = std.c; 228 + const O_NONBLOCK: c_int = @bitCast(libc.O{ .NONBLOCK = true }); 229 + 230 + // usage with fcntl 231 + const flags = libc.fcntl(fd, libc.F.GETFL); 232 + _ = libc.fcntl(fd, libc.F.SETFL, flags | O_NONBLOCK); 233 + ``` 234 + 235 + `libc.O` is a `packed struct(u32)` that varies by `native_os` — `@bitCast` gives the correct integer for the target platform. 236 + 222 237 ## networking 223 238 224 239 `std.net` is gone. use `Io.net`: