3 ms·
This is just like Zig's C compiler
by arjvik 4y ago
This is just like Zig's C compiler
- generichuman 4y agoZig doesn't have a C compiler yet, it bundles clang. Someone in the community was working towards a C compiler in Zig though. ImportC is basically a C frontend for the D compiler, semantics are close enough but there are some changes to be made still.
- csande17 4y agoZig does have "translate-c", which attempts to convert C code to Zig code. Similarly to D, it's used for a feature to automatically import C headers into a Zig program. But even that's based on libclang's parser and AST.
- p0nce 4y agoImportC has bitfields and #pragma pack but not translate-c.
- flohofwoe 4y agoThe important part in Zig is that you don't need another compiler toolchain to build a mixed C/C++/ObjC project, how that's implemented under the hood (e.g. embedded clang vs self-made compiler) is an implementation detail. I'd argue that C++ and ObjC support is just as important as C support for real world projects (because a lot of important libraries are written in C++ unfortunately, and ObjC is needed for calling into macOS system APIs - although this could also be done more awkwardly by going through the ObjC C runtime). The one big downside of embedding Clang and the whole of LLVM is the compiler's executable size (somewhere around 170 MB).