5 ms·
Does it also work with C++? If so, it seems like a very good alternative compared to the MSVC + clang-cl toolchain in Windows (which you need to install gigabyt
by cyber_kinetist 5y ago
Does it also work with C++? If so, it seems like a very good alternative compared to the MSVC + clang-cl toolchain in Windows (which you need to install gigabytes of libraries before doing any development).
Also, does it also work with build systems like CMake flawlessly? (I know that you can use Zig as a build system, but I would still want to leverage the ecosystem of C++ libraries compatible with CMake.)
- afranchuk 5y agoBest to try it to figure it out. I tried compiling a trivial main function with `zig c++` (without cross compile) and the produced binary crashed when run. I think it's far more battle tested for C. But I look forward to C++ being improved as well.
- nicoburns 5y agoI haven't actually used it myself, but I believe yes to both. It wraps clang, and while it's not quite as simple as "just a wrapper" it should be able to do anything that clang can do.
- cyber_kinetist 5y agoRepeating my other comment, but I'm also interested if the STL also works out-of-the-box (is libc++ included?). Without it you can't really say it supports C++.
- nicoburns 5y agoCan't find a definitive answer to this, but this merged PR looks like it might implement support for this: https://github.com/ziglang/zig/issues/4786 https://github.com/ziglang/zig/issues/4786
- cyber_kinetist 5y agoThat's good news. I might try using it someday...
- yellowapple 5y ago> Does it also work with C++? It wraps clang, so it supports whatever clang supports, C++ included. > Also, does it also work with build systems like CMake flawlessly? I haven't personally tried it, but I'd expect that if all else fails you could add a step in build.zig to run CMake and then link against whatever library you just built.
- cyber_kinetist 5y agoDoes this include libc++ (compiled shared library of the STL complete with headers and debug symbols?) Although I hate most parts of the STL I still find myself using some parts of it (std::vector, std::string, <algorithm>, <type_traits>, etc.). Maybe I can link libc++ as an external library but then that's too much busywork needed for Zig to be a complete C++ dev environment out-of-the-box.
- a_e_k 5y agoAs an experiment a while back, I had tried in on a small project of mine that uses std::vector, std::string, and <algorithm> (though not a whole lot else). It built, ran, and passed my test suite.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- flohofwoe 5y agoYes, Zig is also a complete C++ and ObjC/C++ toolchain. For some operating system it also comes with system headers (e.g. for building Win32 or macOS applications). It should be possible to use Zig as clang replacement in traditional C/C++ build systems, just by replacing the compiler invocation with 'zig cc', although I heard this sometimes causes subtle problems because of the space between 'zig' and 'cc', so it probably needs to be wrapped with a script file or maybe alias.