#Info on how I should be using C in Zig?
1 messages · Page 1 of 1 (latest)
the "replacement" for it is to use addTranslateC in the build.zig, then create a module with that translated file as the root, and then add it as a module import whereever you need.
this solves the annoying issue people often face where you have cImport called multiple times, and is just better suited to be in the build system
eg,
.root_source_file = <path to .h>,
.target = target,
.optimize = .optimize,
});
exe.root_module.addImport("header", c_header.createModule());```
Then in your Zig code:
```const c = @import("header");```
tyvm ❤️
if im using a system library how do I do the .root_source_file?
you make a .h file that does the #include. that's one of the problems with addTranslateC right now