By contrast, the Plan 9 C compiler does use the header when linking. Header files contain a prama statement with library name, removing the need for linker flags.<p>See: <a href="http://plan9.bell-labs.com/sys/doc/comp.html" rel="nofollow">http://plan9.bell-labs.com/sys/doc/comp.html</a>
> instead of writing yet another wrapper around yet another set of poorly standardised existing tools, I'm using aimake, a build system I wrote originally for NetHack 4<p>Not sure I'll be able to use aimake, as it's not invented here ;-)<p>On a more serious note, it sounds a bit strange to claim this isn't built on other tools -- he uses various compilers and linkers, and other utilities for installation etc. Eg CMake might not be perfect, but at least I couldn't find any kind of rationale for why cmake or tup might not work perfectly fine for the purpose? Maybe I skimmed too quickly?
Considering the glut of C build systems (often built on top of GNU Makefiles) as proof that this is a complicated field, this is a surprisingly undiscussed aspect of programming. Thanks for this link!
For the preprocessing part of the problem this might be useful: <a href="https://news.ycombinator.com/item?id=8356100" rel="nofollow">https://news.ycombinator.com/item?id=8356100</a>
This is probably the first time I really get what is happening during a build (despite having written a few C programs and Makefiles). Thanks for writing!
If anyone ever finds a linux C program that doesn't quite do what they need, my advice is this as I've had great success with it in the past modifying ntfs3g and the like..<p>Download the source package and open it in NetBeans! For what I needed clicking build JUST WORKED. For my purposes it was a short trip to adding some new arg commands and modifying functionality, then building and packaging it back into a .deb ready to go. I'm not sure if this is still the case, but NetBeans was pretty fantastic for this just 2 years ago.
For goodness sake, keep writing these type of articles! I am now digging into "Memory management in C programs" and I hope the rest of the articles are as good as these two.
<i>"The algorithm used by the vast majority of preprocessors is very simple: the preprocessor has a hardcoded list of directories, which the user can add to, and the preprocessor will scan them in sequence until it finds the file it's looking for. In the case of include "file.h", it will also scan the directory containing the source file."</i><p>At least for gcc, that is not quite correct. It also has a <i>list</i> of user directories.<p>The user list starts as a list containing only the current directory, but can be extended with command-line options. See <a href="https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html" rel="nofollow">https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html</a>