+-
c – 什么是“pch.h”,为什么需要将其作为第一个头文件包含在内?
#include "pch.h"
#include <stdio.h>
#include <string.h>

什么是“pch.h”?为什么需要将其作为第一个头文件包含在内?

最佳答案
pch代表 precompiled header.

In computer programming, a precompiled header is a (C or C++) header file that is compiled into an intermediate form that is faster to process for the compiler. Usage of precompiled headers may significantly reduce compilation time, especially when applied to large header files, header files that include many other header files, or header files that are included in many translation units.

To reduce compilation times, some compilers allow header files to be compiled into a form that is faster for the compiler to process. This intermediate form is known as a precompiled header, and is commonly held in a file named with the extension .pch or similar, such as .gch under the GNU Compiler Collection.

在Visual Studio中,预编译的头文件通常命名为“pch.h”(用于基于控制台的应用程序),但可以使用不同的名称,或者根本不使用它.预编译头文件(如果有)由项目设置决定.

如果预编译头文件是“pch.h”并且编译选项是/ Yu,则Visual Studio将不会在源文件中的#include“pch.h”之前编译任何内容;它假设源中包含该行的所有代码都已编译.

点击查看更多相关文章

转载注明原文:c – 什么是“pch.h”,为什么需要将其作为第一个头文件包含在内? - 乐贴网