3 ms·
You only #define _CLIB_IMPL 1 in one translation unit when compiling.
by hmry 4y ago
You only #define _CLIB_IMPL 1 in one translation unit when compiling.
- leni536 4y agoAh, OK. I was confused how that was supposedly used. I suppose header-only C libs are somewhat a pain, as inline does not work the same way as in C++, and static may cause code bloat when inlining does not happen in multiple TUs.
- linkdd 4y agoC Header-only libraries do not exist. It's just `#include "foo.c"` with extra steps.
- badsectoracula 4y ago`#include "foo.c"` would repeat the implementation in multiple object files which is both wasteful and, if not using static, create conflicting symbols.
- linkdd 4y agoYou missed the "with extra steps". #define XXX_IMPL #include "xxx.h" And #include "xxx.c" Are exactly the same trash.
- badsectoracula 4y agoNo they are not, the former allows you to include the header file in multiple .c files, the latter does not.