Skip to content

Support Zig 0.17.0 - #127

Merged
jinzhongjia merged 8 commits into
mainfrom
feat/zig-0.17
Oct 6, 2026
Merged

jinzhongjia merged 8 commits into
mainfrom
feat/zig-0.17

Conversation

@jinzhongjia

@jinzhongjia jinzhongjia commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Adds Zig 0.17.0 support while keeping Zig 0.16.0 working. CI now builds and tests both versions.

Dependency

  • Pin webui to f1b28ee, which includes Fix build with Zig 0.17.0 webui#719. The previous pin failed to configure on Zig 0.17 with no field named 'Debug' in enum 'lang.Optimize'. The C API in webui.h is unchanged.

Library

  • Type reflection: Zig 0.17 replaced Fn.params with param_types and moved Fn.is_var_args / Pointer.is_const into attrs. binding now detects which layout is available at comptime. tuple.fnParamsToTuple takes plain parameter types, because std.builtin.Type.Fn.Param no longer exists.
  • Formatting: std.fmt.bufPrintZ was removed, and its replacement std.mem.printSentinel does not exist on 0.16. Both are wrapped behind an internal helper.
  • Build: Zig 0.17 caches the configure phase, so addEmbeddedDir kept stale file lists after assets were added, deleted, or renamed (deleting a file made the build fail). Each scanned directory, and the examples directory, is now declared with dependOnDirectoryContents.
  • Windows: Build.dupe now returns []const u8, so addEmbeddedDir copies each path before rewriting \ to / in place. This branch only compiles on Windows hosts, so it was checked locally by type-checking build.zig for a Windows host and cross-compiling the examples and tests for x86_64-windows.

Examples

  • Added compat.bufPrintZ, and replaced the removed ** array repetition operator with @splat.

Tests

  • New unit test that instantiates binding with every supported callback parameter type. Before this, the reflection path was only exercised by building the examples.

Verification (macOS arm64)

Check 0.16.0 0.17.0
zig build examples (static / dynamic) pass pass
zig build test 26/26 26/26
zig build docs pass pass
python -m unittest discover -s tests pass pass
zig fmt --check pass see note

Note: 0.17's zig fmt rewrites @intFromEnum / @enumFromInt into @backingInt / @fromBackingInt, which do not exist on 0.16. The old builtins are only deprecated on 0.17, so they are kept as is. The lint job still runs on 0.16 through minimum_zig_version.

Zig 0.17 rewrote type reflection: `Fn.params` became `param_types`, and
`Fn.is_var_args` / `Pointer.is_const` moved into `attrs`. It also removed
`std.fmt.bufPrintZ`. Detect the available layout and API at comptime so
the bindings keep building on Zig 0.16.

`tuple.fnParamsToTuple` now takes plain parameter types instead of
`std.builtin.Type.Fn.Param`, which no longer exists in 0.17.
The unit tests did not instantiate `binding`, so changes to its comptime
type reflection were only caught by building the examples.
Add `compat.bufPrintZ` for the removed `std.fmt.bufPrintZ`, and build the
event_handling separator with `@splat` instead of the removed `**` array
repetition operator. Both forms also work on Zig 0.16.
Zig 0.17 caches the configure phase, so `addEmbeddedDir` kept stale file
lists after assets were added, deleted, or renamed. Declare each scanned
directory with `dependOnDirectoryContents`, and do the same for the
examples directory. Zig 0.16 has no configure cache and is unaffected.
Pin webui to f1b28ee, which includes webui-dev/webui#719. The previous
pin failed to configure on Zig 0.17 with `no field named 'Debug' in enum
'lang.Optimize'`. The C API in webui.h is unchanged.
On Zig 0.17, `Build.dupe` returns `[]const u8`, so rewriting `\` to `/`
in place failed to compile. The branch only builds on Windows hosts,
so other platforms did not catch it.
@jinzhongjia
jinzhongjia merged commit e89087c into main Oct 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant