3 ms·
As much as I love zero-configuration software, it seems implausible to do it for C/C++ as anything other than a gimmick. Even a simple program may need to link
by kevingadd 5y ago
As much as I love zero-configuration software, it seems implausible to do it for C/C++ as anything other than a gimmick. Even a simple program may need to link against a library or two to pull in some APIs unless absolutely every single function you use is in libc and it gets linked by default. If you want to target multiple platforms it gets worse because you may need things like per-platform defines set by the build system or per-platform .c/.h selection. Once you approach that level of complexity you should strongly consider just using existing build ecosystems like cmake - not because they're pleasant, but because the people maintaining them have identified a lot of the sharp edges that you're going to run into.
The performance of builds with this seems like it could also scale badly once your app gets big enough, since it doesn't seem to do incremental builds or avoid re-building individual .c files if a source file and its dependencies (headers) haven't changed.
Seems handy if you just want to fiddle around with a .c and .h file pair without writing a makefile, though!
- jhgb 5y agoI imagine that using Zig to compile C++ projects is probably a better idea?
- cyber_kinetist 5y agoCan you actually write Zig build scripts to build C++ projects? If that’s possible then that might be a good option.
- jhgb 5y agoJudging from https://zig.news/kristoff/make-zig-your-c-c-build-system-28g5 https://zig.news/kristoff/make-zig-your-c-c-build-system-28g... , this should be possible. Considering Zig's features, I wonder if even the automated build logic in this Qb system couldn't be ported into a Zig build script completely.
- flohofwoe 5y agoYes, here is an example for a non-trivial mixed C/C++ project: https://github.com/floooh/sokol-tools/blob/master/build.zig https://github.com/floooh/sokol-tools/blob/master/build.zig Compared to cmake this means giving up IDE support like Xcode or Visual Studio though, it's really "just" a build system, not a meta-build system which can generate IDE project files. The Zig build system also has some minor warts that don't matter much for a pure Zig project but do matter for C/C++ projects, mainly that build settings of dependencies (like header search paths or linker input) mostly don't automatically 'travel' upwards to the root, instead each dependency and root project needs to be configured on its own. There are plenty of upsides too though, like much simplified cross-compilation, all in all it looks very promising.
- cyber_kinetist 5y agoCan it also generate compile_commands.json automatically? That is the only thing you need for IDE/editor support nowadays.
- flohofwoe 5y agoAFAIK no, sounds like a good feature to have though.
- e12e 5y ago> Seems handy if you just want to fiddle around with a .c and .h file pair without writing a makefile, though! Doesn't make already do this, with built-in targets? Eg, with hello.c, hello.h, no Makefile: make hello (not sure about header files though, I know it works for simple c files at least).
- jcelerier 5y agothere's a whole lot of default rules in GNU make: https://www.gnu.org/software/make/manual/html_node/Implicit-Rules.html https://www.gnu.org/software/make/manual/html_node/Implicit-... but not sure they are portable