4 ms·
There are multiple comments remarking on the header-only implementation, confused regarding linker errors and why this is desirable. Look into stb lib, which in
by cornstalks 1y ago
There are multiple comments remarking on the header-only implementation, confused regarding linker errors and why this is desirable. Look into stb lib, which in my opinion popularized this idea: https://github.com/nothings/stb?tab=readme-ov-file#how-do-i-use-these-libraries https://github.com/nothings/stb?tab=readme-ov-file#how-do-i-...
- legobmw99 1y agoIn particular, you can define the implementation flag and include the header in a .c file with no other contents to recover the more “traditional” build set up where you have a separate TU dedicated to the library. I quite like the flexibility it provides in terms of making “unity builds” very easy, and scaling down quite well to small, single-TU projects with minimal build set ups.
- FerkiHN 1y agoExactly! That flexibility was one of my goals. Making integration smooth for both small embedded projects and larger codebases with unity builds — glad to hear it resonates.
- legobmw99 1y agoI first encountered the idea relatively recently with Clay [1] and I have been a fan since. Once you get past the “huh, weird” stage it has a lot of benefits! 1: https://github.com/nicbarker/clay https://github.com/nicbarker/clay
- FerkiHN 1y agoThanks! Yes, stb-style header-only libs were definitely an inspiration. I know some devs find the approach confusing, especially with linker errors if *_IMPLEMENTATION isn't handled correctly. I tried to keep it simple and clearly documented, but feedback like this helps improve it.