I have some confusion that I want to clear out.
Recently my project got somewhat big and I can't manage it in a single C file, so I split it into multiple files, which raises some concerns :-
Q.1 In multi file project each C file will be compiled independently and then linked together, does it generate different code than as oppose to creating whole project in one single C file and compiling that? I.e Does it produce less optimized code ?
Q.2 Including a header file where it is not needed, does it have any detrimental effect on code? Like say I include all my header files in single header file and than I include that in every C file. Is this bad or it doesn't matter ?
Q.3 Consider I have three files,
My_Interface.h My_Interface.c main.c
I see many times it's recommended to include .h file in it's own .c file but as I understand .h file is made for including in other .c files like main.c etc. What is the purpose of doing that ? The program produces no error even if I don't do that. ( by not including .h file into it's own .c file)
Thank you for time.