4 ms·
It adds a new dependency - the c language frontend - aka clang - surely the zig compiler emits LLVM IR, not C code?
by richardwhiuk 4y ago
It adds a new dependency - the c language frontend - aka clang - surely the zig compiler emits LLVM IR, not C code?
- daurnimator 4y agozig supports importing C headers via the special built-in `@cImport`. That feature requires a C language front end to operate. https://ziglang.org/documentation/0.10.1/#Import-from-C-Header-File https://ziglang.org/documentation/0.10.1/#Import-from-C-Head...
- deleted 4y ago[deleted]
- tristan957 4y agoZig has a C backend that supports something like 99% of all Zig if I'm remembering the number correctly. Zig has almost completely solved the bootstrap problem.
- trashburger 4y agoThis isn't quite correct. Yes, it can output C code; however the result is not very readable at all, and fails the DFSG on generated code. It _is_ useful for compiling Zig code to targets which aren't supported by LLVM, however.
- haberman 4y agoDo you have a reference for this? Does it use a C backend that is part of LLVM, or is it something Zig-specific? What are its limitations? Can it compile libraries to C, or only entire applications? I have wanted Rust and Zig to support compile-to-C for a while, so this is exciting news for me. One thing that would particularly interest me is if functions intended to be inlined could be emitted into .h files.