4 ms·
It says it's a C frontend for `zig translate-c` which translates C code to Zig code. `zig translate-c` is not required for most Zig projects or even for most Zi
by anonymoushn 2y ago
It says it's a C frontend for `zig translate-c` which translates C code to Zig code. `zig translate-c` is not required for most Zig projects or even for most Zig projects that interop with C.
- slowmovintarget 2y agoThank you. I also started reading through the Zig overview [1] and near the end of that document it says this: "Not only can Zig compile C code, but there is a very good reason to use Zig as a C compiler: Zig ships with libc." From the doc, IIUC, compilation of header files and other C code allows Zig to do direct interop with no intermediaries. Seems useful. [1] https://ziglang.org/learn/overview/ https://ziglang.org/learn/overview/
- 3836293648 2y agoThat's just wrapping clang. They're working on replacing it
- Laremere 2y agotranslate-c is not required for compiling pure Zig code. However, the plan is to remove the "@cImport" built in. So if your project is importing a c header, in the future you'll add build step translating it from c to Zig, and then you import it into your Zig code as a module.
- fuzztester 2y agowhat is the reason for this change? zig less than newbie here. I've only just recently started reading the zig overview, although I have been reading hn posts about zig with interest for some time.
- Laremere 2y agoPrimary reason is that it removes a dependency on libclang, and as such is required to remove the LLVM dependency.
- 6keZbCECT2uB 2y agoHow does this work with things which are expressible only in C? For example, Pascal strings with flexible array members? I guess since you said header, you keep everything opaque and create a header for that which gets translated to Zig.
- girvo 2y agoIt's super exciting. c2nim is one of the things that makes using Nim in _super_ odd places (like professional embedded firmware development) feasible, and translate-c brings Zig that much closer to what I'd love from it! Embedded Zig is going to be rad, once we get there.