Commit 659af4a
P1: fix Zig FFI to build and match the Idris2 ABI (#38)
`zig test src/main.zig -lc` failed to compile under Zig 0.14.0 with 9
"unused function parameter" errors. In Zig 0.14 an unused function
parameter is a hard error; the leading-underscore naming convention does
NOT exempt a parameter from the unused-parameter check. The affected
stub functions were `futharkiser_compile`, `futharkiser_compile_file`,
`futharkiser_execute`, and `futharkiser_transfer`.
Fix (house idiom, per alloyiser exemplar): rename the underscore-prefixed
parameters to plain names and discard them with `_ = name;` statements at
the top of each function body. This keeps the not-yet-implemented stubs
valid while preserving the exact C-ABI signatures.
ABI conformance (Idris2 is the source of truth) is unchanged and verified:
- All 14 `C:futharkiser_*` symbols in
src/interface/abi/Futharkiser/ABI/Foreign.idr have a matching
`export fn` (no missing, no extra).
- The Result enum integer values (ok=0, error=1, invalid_param=2,
out_of_memory=3, null_pointer=4, compilation_failed=5,
backend_unavailable=6, shape_mismatch=7) match
Types.idr `resultToInt` exactly.
- Exported symbol names and arities are unchanged.
Verification:
- `zig test src/main.zig -lc` -> all 9 tests pass, 0 errors/warnings.
- `idris2 --build futharkiser-abi.ipkg` -> exit 0.
Only src/interface/ffi/src/main.zig was changed.
Claude-Session: https://claude.ai/code/session_019xMKB3T4Vo5FYC7Czx3JSH
Co-authored-by: Claude <noreply@anthropic.com>1 parent 75388ef commit 659af4a
1 file changed
Lines changed: 18 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
| 157 | + | |
| 158 | + | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
183 | | - | |
184 | | - | |
| 185 | + | |
| 186 | + | |
185 | 187 | | |
| 188 | + | |
| 189 | + | |
186 | 190 | | |
187 | 191 | | |
188 | 192 | | |
| |||
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
208 | | - | |
209 | | - | |
| 212 | + | |
| 213 | + | |
210 | 214 | | |
| 215 | + | |
| 216 | + | |
211 | 217 | | |
212 | 218 | | |
213 | 219 | | |
| |||
302 | 308 | | |
303 | 309 | | |
304 | 310 | | |
305 | | - | |
306 | | - | |
307 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
308 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
309 | 318 | | |
310 | 319 | | |
311 | 320 | | |
| |||
0 commit comments