4 ms·
There's a blog post that describes this: https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html https://andrewkelley.me/post/zig-cc-po
by SloopJon 5y ago
There's a blog post that describes this:
https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html https://andrewkelley.me/post/zig-cc-powerful-drop-in-replace...
HN discussion:
https://news.ycombinator.com/item?id=27872596 https://news.ycombinator.com/item?id=27872596
previous discussion:
https://news.ycombinator.com/item?id=22679138 https://news.ycombinator.com/item?id=22679138
- gavinray 5y agoI know of "zig cc" -- the same article says: There are some follow-up issues related to zig cc which are still open: - ... - support compiling and linking c++ code Did this change recently? I've tried "zig cc" for C++ before and asked on the Discord and was told it wasn't capable of it. rayga@DESKTOP-88A51E5 MINGW64 ~/Projects/tmp/zig-cc-test $ zig version 0.9.0-dev.959+f011f1393 rayga@DESKTOP-88A51E5 MINGW64 ~/Projects/tmp/zig-cc-test $ zig cc test.cpp test.cpp:1:10: fatal error: 'iostream' file not found #include <iostream> ^~~~~~~~~~ 1 error generated. rayga@DESKTOP-88A51E5 MINGW64 ~/Projects/tmp/zig-cc-test $ clang test.cpp rayga@DESKTOP-88A51E5 MINGW64 ~/Projects/tmp/zig-cc-test $
- kristoff_it 5y agoyou need to use `zig c++` to compile cpp code
- gavinray 5y agoOh, sweet thanks. Indeed it also right under "zig cc" in the output for "zig --help" too, if that wasn't clear enough: $ zig --help Usage: zig [command] [options] Commands: cc Use Zig as a drop-in C compiler c++ Use Zig as a drop-in C++ compiler
- SloopJon 5y agoAt the end of the post is a link to a Github issue to "support compiling and linking c++ code": https://github.com/ziglang/zig/issues/4786 https://github.com/ziglang/zig/issues/4786 It was closed in March of 2020.
- AndyKelley 5y agohttps://ziglang.org/download/0.8.0/release-notes.html#zig-c https://ziglang.org/download/0.8.0/release-notes.html#zig-c > zig c++ is equivalent to zig cc with an added -lc++ parameter, but I made a separate heading here because I realized that some people are not aware that Zig supports compiling C++ code and providing libc++ too! You can also mix Zig code and C++ like this: zig build-exe foo.zig bar.cpp -lc++ -lc