#How to translate-c a system header?
1 messages · Page 1 of 1 (latest)
zig translate-c -lc <source or header file(s)> > file.zig
If necessary add -I<IncludePath> and another libs -lpthreads.
Does it mean that I must know the exact header location on every system? When I use @cImport("curl/curl.h") it just works with -lcurl but I need to edit the translation. Can I somehow use the same knowledge the @cImport function has about the system?
If it's installed on the system, -lc (linklibC()) already detects it on the system.
See zig libc config.
You only need to specify the curl inc/lib path if there is a custom path.
i don't have curl but creating a file like this (named test.h):
#include <stdio.h>
and then running zig translate-c -lc test.h > out.zig worked afaict
also, if you only have to edit the translation it should be somewhere in .zig-cache/o. so you can just copy it out of there and use that instead of @cImport