4
votes

Does including unneccesary header files increase my executable or affect time of compiling.

For ex. for basic input output programs i definitely need stdio.h , but if i also include other headers like time.h, stdlib.h ,math.h how it would affect the executable.

5

5 Answers

9
votes

It won't affect the size of executable but yeah it will effect the time for compiling.

More includes more compile time.

4
votes

Header files are just declarations - hence longer compilation times.

But they do not add any extra to execution times.

1
votes

yes It Affects the Compile time of the program the more includes you use more preprocessing is required hence affects the compile time

0
votes

The title is more general then the question.

Unnecessary headers could also mean "evil" headers, mainly if #included before other necessary headers.

"Random" definitions and/or "evil" #defines included prior to what is necessary could mess up what is #included afterwards and with this definitly "affect" your executable.

0
votes

Mostly Compile times are affected, however it has no effect on execution times so it's always better to add the header files that are required in the program