I am a total nooooob, so don't expect that I know too much about precompiled libraries.
It is about pre-compiled
headers (PCH). That's a technique to speed up the compilation process.
Currently, PCH is only used for MSVC under Windows and for each target the compiler builds PreCompiled.cpp as very first file. It creates a big binary file that contains the content of all header files of the corresponding PreCompiled.h.
Remark:
Because the creation of this binary file is quite expensive it must be avoided to re-create it too often. This can only be achieved if files are added that almost never change. So, that's why for PCH only 3rd party header files should be considered but not application header files.
If the compiler continues with the next source files then it replaces the "PreCompiled.h" with the content of the binary file. This avoids that the compiler has to open each header file separately that is listed in the PreCompiled.h and thus considerably speeds up the process. With activated PCH for MSVC we get a reduction of the build time of 40-50%.
But what is _PreComp_? When should an include be inside _PreComp_?
Because PCH is optional and not yet ready to be used for other compilers than MSVC it must be avoided to slow down the build process for them. Therefore it must be avoided that they had to include all headers of a PreCompiled.h and that's why the PreCompiled.h files have a guard of this form:
Code: Select all
#ifdef _PreComp_
...
include all needed headers for the target
#endif
However, when building a normal source file and the compiler needs the declaration of a used class or function then the header of this class or function has to go inside the #ifndef _PreComp_/#endif block.
To formulate this as a rule:
A header must be added inside an #ifndef _PreComp_/#endif block if the compiler requires a declaration that is provided by this file AND it's not already included AND if this header is listed in the target's PreCompiled.h file.
I also noticed, that the definition of _PreComp_ has been commented out since at least 2011 (GitHub doesn't go further back):
https://github.com/FreeCAD/FreeCAD/blob ... fig.h#L321. So are _PreComp_ even still used or will ever come to use again?
If a header is already included by an application header file then it's not needed to include again. That's why some _PreComp_ are empty or commented out.