Lyricdev
GitHub

LYR-BLD0005

a module cannot be made from a C header

error · spec 15-project

Reported when a header a package's bindings names does not compile — with what the C compiler said — or when the C compiler writes no syntax tree of it, which only zig cc and clang do. Nothing is built; the exit code is 1.

Explanation

bindings = [{ header = "native/geo.h", module = "geo" }] asks the build to write the module <package>.geo from the header: its functions as extern "C" declarations, its structs, enums, typedefs and constants, each in the types they have on the build's target. To know them, the build has the C compiler read the header — with the package's include and defines, for that target — and write its syntax tree. A header that does not compile has no tree, and the message quotes the C compiler.

Make the header compile as the package's own C sources would see it: a missing include directory belongs in include, a definition the header expects in defines. The tree comes from zig cc or clang; with gcc as the C compiler, the build looks for zig, and where there is none it stops here — set LYRIC_CC to zig or clang. lyric bindgen <header> makes the same module on the command line, to see what the build would read.

Wrong

//- lyric.toml
[package]
name = "app"
version = "0.1.0"

[native]
bindings = [{ header = "native/geo.h", module = "geo" }]
//- native/geo.h
int geo_add(int a, int b)
//- src/main.lyr
fn main(): void {
}
//- lyric.toml
[package]
name = "app"
version = "0.1.0"

[native]
bindings = [{ header = "native/geo.h", module = "geo" }]
//- native/geo.h
int geo_add(int a, int b);
//- src/main.lyr
fn main(): void {
}