Been lurking in the docs and doing simple contrived examples for a month or so now. I can follow why people are spending effort to repackage popular C libraries to make them easy to integrate into the build system i.e. All Your Codebase · GitHub. However, there seems to be just as much effort to build c++ projects with zig. Why spend the effort if you can’t call the c++ libraries with zig? Am I missing something obvious there? I would be interested in using zig to work with the DCMTK libraries (GitHub - DCMTK/dcmtk: Official DCMTK Github Mirror), but they are c++ and don’t already have C wrappers ready to use.
Even tho a lot of projects are written in c++ most of then still have C api. Or in case of stockfish in all you codebases you use it through IPC.
Also some of projects useful as application e.g. VVVVVV and it is nice to have better option to build it.
1 Like
Another reason is easing cross compilation.
5 Likes
It’s usually not too complicated to make C bindings on your own even if the project doesn’t provide them already. There will be some annoyance (you need to prebake generics, sometimes you will need to heap allocate types, manual triggering of destructiors, …), but if the library does enough heavy lifting, it can be worth it.
Case in point, that’s how the Zig compiler uses llvm.
2 Likes