Don't you get linker errors when a project includes this header twice in different translation units? If not, please explain how.
Don't you get linker errors when a project includes this header twice in different translation units? If not, please explain how.
I've included many single .h/.c pair libraries before in my projects and given the of simplicity that was never a pain point.
There's this bizarre cultural difference you see between people who learned to program on windows compared to people who learned to program on unix wherein the Windows crowd don't see the value of having an easily reproducible build system because. Usually this results in some combination of needlessly-complicated scripts and checking binary builds of dependencies into version-control.
Requiring you to include a header-file while also defining a specific constant in only one place that turns the header file into a c-file is actually one of the more benign workarounds you see.
Naturally people love to complain about Windows.
Also nowadays there is vcpkg and conan.
As I recall I just added the files to the project, possibly configured a define or five, and then compiled.
Tedious when it's tons of directories, but a breeze with just a pair of files.
That said, I get that this buys you a bit of flexibility in build management.
Even C++, and considering templates, if you want to use external templates optimization you need implementation files, and then there are modules (already working in clang/VC++).
Personally I would probably add a gif.c to my project which does nothing but include the header with the define set, at least if I'm going to need a gif decoder in more than one place. Probably many (most?) projects only need this library in one file anyway, in which case I'd just include it from that file and be done.
edit: Yeah, defining *_IMPLEMENTATION appropriately would address these issues.