Does #include affect program size?

后端 未结 8 956
一整个雨季
一整个雨季 2021-01-13 09:07

When my cpp file uses #include to add some header, does my final program\'s size gets bigger? Header aren\'t considered as compilation units, but the content of

相关标签:
8条回答
  • 2021-01-13 09:46

    With modern compilers included files only affect the binaries size if they contain static data or if you use normal or inline function that are defined in them.

    0 讨论(0)
  • 2021-01-13 09:47

    It depends on the contents, and how your compiler is implmented. It is quite possible that if you don't use anything in the header your compiler will be smart enough to not add any of it to your executable.

    However, I wouldn't count on that. I know that back in the VC++ 6 days we discovered that meerly #including Windows.h added 64K to the excecutable for each source file that did it.

    0 讨论(0)
提交回复
热议问题