ssteinbach/c_call_zig
Small example of calling a static zig library from C code.
Example repository for calling zig functions from C. Zig has some nice reflection based JSON parsing ability, this exposes a c function that uses that to parse a C-struct out of JSON and return it.
> make
> ./c_to_zig_json_reader
There is a (small) unit test in src/json_reader.zig
.
> make test
When building the static library to wrap in C, make sure the build.zig includes:
const lib = b.addStaticLibrary("zigJsonReader", "json_reader.zig");
lib.bundle_compiler_rt = true;
Additionally, the header file is written by hand.