(no title)
saidinesh5 | 15 days ago
It's a tradeoff people make between ease of integration - just download the .h file into your project folder and #include it in your source file instead of worrying about source build system vs target build system, cross compiling headaches etc...
And compilation times: any time you change any of your source files, your compiler also has to recompile your dependencies. (Assuming you haven't used precompiled headers).
robotpepi|15 days ago
saidinesh5|15 days ago
What you can instead do is just put the add function declaration in add.h that just tells the compiler that add function takes two integers and returns an integer.
You can then put the add function definition in add.c , compile that to an add.o and link it to your main.o at link time to get your final binary - without having to recompile add.o every time you change your main.c.Precompiled headers: https://maskray.me/blog/2023-07-16-precompiled-headers
yxhuvud|15 days ago
The whole thing is essentially a workaround for lack of sufficiently good/easy ways to package code in the ways people want to use it.
atiedebee|14 days ago