mardi 5 mai 2015

Are unnecessary include files an overhead?

I have seen a couple of questions on how to detect unnecessary #include files in a C++ project. This question has often wondered me, but I have never had a satisfactory answer.

If There are some header files included which are not being used in a c++ project, is that an overhead ? I understand that it means that before compilation the contents of all the header files would be copied into the included source files and that would result in a lot of unnecessary compilation. How far this kind of overhead speread to the compiled object files and binaries ?

Aren't compilers able to do some optimizations to make sure that this kind of overhead is not transferred to the resulting object files and binaries ?

Considering the fact, that I probably know nothing about compiler optimization, I still want to ask this, in case there is an answer.

As a programmer who uses a wide variety of c++ libraries for his work, what kind of programming practices should I follow to keep avoiding such overheads ? Is making myself intimately familiar with each library's working the only way out ?

Aucun commentaire:

Enregistrer un commentaire