Keep in mind that every source file you compile includes an independent compiler call. With each call, the compiler must read the header file in each included file, parse it, and create a character table.
When you use one of these “include the world” header files in many source files, this can significantly affect build time.
There are ways to mitigate this; for example, Microsoft has a precompiled header function that essentially saves a character table for later compilation.
However, there is one more consideration. If I am going to use your WhizzoString class, I will not need to set the headers for SOAP, OpenGL and what you have. In fact, I would prefer WhizzoString.h to include only headers for types and characters that are part of the public interface (i.e. the Material that I will need as a user of your class).
As much as possible, you should try switching from WhizzoString.h to WhizzoString.cpp:
Ok
// Only include the stuff needed for this class
IT'S BETTER:
If users of your class never need to create or use a bar type, and the class does not contain any Bar instances, then it may be sufficient to provide only a direct Bar declaration in the header file (WhizzoString. Cpp will have #include "bar.h" ). This means that anyone, including WhizzoString.h, can avoid including Bar.h and everything it includes.
source share