Commit 84162aa
P1: fix Zig FFI to compile under Zig 0.14.0 (#166)
## Summary
The Zig FFI layer (`src/interface/ffi/src/main.zig`) did not compile
under Zig 0.14.0. This fixes the two reported errors (and confirms there
are no further ones), with no change to the C ABI surface.
## Errors and fixes
1. **`extern struct cannot contain a field of type 'mem.Allocator'`**
(was at line ~94)
- `Handle` and `DbConnection` were declared as `extern struct` while
holding a `std.mem.Allocator` field. Zig 0.14 rejects this because
`Allocator` is not extern-ABI-compatible.
- These handles only ever cross the C boundary as opaque `?*T` pointers,
so their layout is private to this module and `extern` was never needed.
Both changed to a normal `struct` (the house idiom — same as the
alloyiser exemplar, which uses a normal `struct` passed as an opaque
pointer).
- All `export fn`s already take/return them as `?*Handle` /
`?*DbConnection`, so the C ABI is unchanged.
2. **`pointless discard of function parameter`** (was at lines ~470–472)
- `verisimiser_vql_free_result` both used `result_ptr` (`if (result_ptr
== 0) return;`) and then redundantly discarded it (`_ = result_ptr;`).
Zig 0.14 errors on discarding a parameter that is also used. Removed the
redundant discard, keeping the real use.
No further errors surfaced after these two fixes.
## ABI preserved (source of truth)
The Idris2 ABI (`src/interface/abi/Verisimiser/ABI/Foreign.idr` +
`Types.idr`) is the source of truth and is unchanged:
- All 24 exported C symbol names preserved 1:1 (every `C:<name>` in
`Foreign.idr` has a matching `export fn <name>`).
- `Result` enum integer values still match `resultToInt`: `Ok=0,
Error=1, InvalidParam=2, OutOfMemory=3, NullPointer=4,
ConnectionFailed=5, ChainCorrupted=6, SidecarUnavailable=7`.
Only `src/interface/ffi/` was touched.
## Verification
- `cd src/interface/ffi && zig test src/main.zig -lc` → all 8 tests
pass, 0 errors/warnings
- `zig build-obj src/main.zig -lc` → exit 0 (clean C-ABI object)
- `cd src/interface/abi && idris2 --build verisimiser-abi.ipkg` → exit 0
- Symbol cross-check: every `C:<name>` in `Foreign.idr` maps to an
`export fn` (empty diff)
> Note: any rust-ci / Hypatia / governance red checks are pre-existing
estate-infra and unrelated to this Zig-only change.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_019xMKB3T4Vo5FYC7Czx3JSH
---
_Generated by [Claude
Code](https://claude.ai/code/session_019xMKB3T4Vo5FYC7Czx3JSH)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent efd2291 commit 84162aa
1 file changed
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
| |||
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
105 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
| |||
469 | 476 | | |
470 | 477 | | |
471 | 478 | | |
472 | | - | |
473 | 479 | | |
474 | 480 | | |
475 | 481 | | |
| |||
0 commit comments