The effect of including a header file in C

What is the effect of including a header file, none of the functions declared in which are used in the source file? Does this affect stack size, etc.?

+3
source share
5 answers

This will have no effect, but it will increase compilation time and make the code more difficult to understand and maintain. You should include only those headers that you really need and delete those that become redundant.

+6
source

It depends on whether there are definitions in the header file or just declarations.

, ISO C , . , "C ". .

, int xyzzy; (, , char big_honkin_thing[9999999];), , , . "", .

, . , , : / , () , , .

, char big[99999] = {'x'}; , 18K 118K.

, typedef extern, .

, , . ( ).

+6

. , , .

Inclusion of a header file whose declarations are never mentioned in that the translation unit does not affect the size of the generated objects. Of course, this will slow down the compilation.

+4
source

This will increase compilation time, but AFAIK there should not be any other changes.

+2
source

Direct access to the source file, compared with access to the source file with the header file, will take less time if there is nothing in the header that could affect the source file.

0
source

All Articles