Precompiled headers

假装没事ソ 提交于 2019-12-01 16:56:25

Precompiled headers are an optimisation used during the compilation process.

Basically, if you compile something like stdio.h with the exact same defines and environment, you can safely assume the result will be the same each time.

So the compiler remembers the "compiled" version of that header so it doesn't have to do it again.

In reality, it tends to be the initial group of headers that makes the difference so, if every one of your source files starts with:

#define XYZZY 42
#include <stdio.h>
#include <stdlib.h>

the first one compiles completely but remembers the state immediately following that third line. The next one can simply throw those three lines away totally and load up the saved state before continuing to compile the rest of the file.

The first time I saw this feature was on Windows with its massive windows.h header file and, believe me, it made a lot of difference to overall build times.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!