Hacker News new | ask | show | jobs
by jandrese 1370 days ago
gcc or clang would crash on the linking step complaining about duplicate symbols. This library is only good for a project that is built in a single .c file.
3 comments

That's not true in this case: if you look at the .c file you can see it actually has no definitions by default and is a relatively normal .h file when it's included.

You can #include it in any number of files as long as exactly one has #define OLIVEC_IMPLEMENTATION.

There are many single-file C "libraries" that work perfectly fine as both "header" and "implementation", and that do not require unity builds (building everything as a single translation unit, e.g., a single .c file). Here is but one famous collection of them: https://github.com/nothings/stb
False.