error ffi-import
What it means#
import c "header.h" { names } reads the header with libclang at compile time (§16.1). The error is reported when the header cannot be found or parsed, or when a listed name does not exist in it or has a type that cannot be mapped to OxL (variadic functions, unions, bit-fields, packed structs, long double, structs passed by value). The same code reports types without a C representation in hand-written extern c fn / export c fn signatures (str, String, List<T>, char, structs by value) and in @c_layout data fields.
Example#
import c "zlibb.h" { deflate } // <- ffi-import (no such header)ffi-import
extern c fn puts(s: str) -> i32 // <- ffi-import: `str` has no C representationHow to fix#
import c "zlib.h" { deflate, inflate, z_stream }For strings use std.ffi: str.toCString() gives an owned NUL-terminated buffer (.asPtr() is a *u8), CStr.fromPtr(p) reads one back; pass structs as *var S. Check the header name and the include path of the native dependency declared in [deps] (for example zlib = { c = "system", header = "zlib.h" }).