I am new, so I appreciate your help and patience in advance. I have written a program in C like this:
main.c
arpsend.h - header w/include guard for arpsend.c functions
arpsend.c - includes <net/if.h>, <pthread.h>, etc.
arprec.h - header w/include guard for arprec.c functions
arprec.c - includes <net/if.h>, <pthread.h>, etc.
The arpsend and arprec files use many of the same kernel library functions and definitions. I have noticed that my program size shot up when I wrote the arprec.c code. It bloated much more than what my code should have. This leads me to conclude that both the arpsend.c and the arprec.c linked the linux library code necessary for their own needs in their respective .c files. The linking is redundant for the project, but necessary for each .c file.
My questions are the following:
if every .c file I add to a project will bloat like this because of kernel and standard library redundancies, wouldn't every program become needlessly bloated? The bloat in my example is probably insignificant (~12k), but I can only imagine the kind of bloat that would happen if I needed to use some graphics library across several different .c files.
Is there a way to avoid this?
Is the recommended solution to simply keep all functions using the same kernel code in one file?
If #3 is correct, doesn't that defeat the point of trying to keep clean code? It's C, so it's not really OOP, but I would like to spread my code out so that I can easily see the makeup of a project.
I apologize if this is redundant. I sifted through the forums here for a couple hours. I couldn't find my exact question. Thanks again for your help