编译代码时,编译器必须查看所有#included 标头以了解如何编译 .cpp 文件中的代码。
对于大型项目(或使用 MFC 等库的项目),这些头文件可能会变得很大,因此需要很长时间才能编译。
Because most of these headers don't change that often (if ever), you can get the compiler to "precompile" them - it processes them and saves its state into a precompiled header. THe next time it compiles, it doesn't need to read and compile all those headers again, so it is much faster.
One requirement in Visual Studio is that if you use a precompiled header, it must be included in every file in the project.
If the project is small, or you don't build it often, then you can just disable the "precompiled header" option (in the project settings. This applies to the whole project). The only effect you'll get is that it may compile more slowly. Or leave the option enabled and just add #include "stdafx.h" as the first include in every file.