Say I #include "math.h" in a simple C program while doing a math calculation so I can use the constant for PI. Then, I take out the usage of 'math.h' without actually removing the #include. Would this irrelevant file still compile and make my program larger or will it be ignored?
Use of pre-processor directive #include
for a header file with no parseable code will not increase the size of the compiled binary.
Typically a header file will only usually include declarations - not definitions. So the inclusion of a C header file will not normally increase the size of the binary anyway.
For example - in a header file this statement int maxlines;
would create the definition of a variable which would be stored in the compiled binary file. The inclusion of the definition would increase the size of the binary.
Function declarations and pre-processor tokens such as int parseFiles(const char *file);
and #include MAX_LINES 80
however will not increase the program size.
One effect of keeping the #include statement will be to increase the time taken to compile slightly.