top | item 44658344

(no title)

dn3500 | 7 months ago

You're supposed to #define GIF_IMPLEMENTATION in only one of your .c files to prevent linker collisions. But yeah I don't get the point. How is this any better than the standard method of putting macros and data definitions in the .h and code in the .c? This is just going to confuse anyone who comes along later and wants to work on the code that uses this thing.

discuss

order

FerkiHN|7 months ago

Totally fair — this pattern can be confusing at first glance. The main motivation is ease of integration: no need to manage extra .c files, no build system tweaks, just drop in one file and go. It’s especially useful for embedded systems, scripts, and small projects where build friction matters. That said, I agree that for larger teams or long-term projects, the classic .h + .c split can be clearer — that’s why the implementation can easily be separated if needed. Appreciate the feedback!