2 ms·
I don't agree, header file libraries are great and the apparent advantage to header/source pair are negligible in practice (I use the STB headers all the time i
by flohofwoe 10y ago
I don't agree, header file libraries are great and the apparent advantage to header/source pair are negligible in practice (I use the STB headers all the time in different projects). One advantage is that you can simply add all the configuration defines (e.g. what assert macro and allocation functions to use, all the configuration options, ...) simply in front of the include statement and you don't need to mess around with the build system or compiler command line options to define those.
Of course you usually wrap the header-only-lib in a central header/source pair of your own, so that those configuration defines and the implementation are in a single place instead of directly including the library header in different places.
- marssaxman 10y agoWhat's the advantage of packing everything into a header file if every single user of this "library" has to unpack it back out again? Why not just ship a header+source file, like civilized people have been doing since the dawn of C?