什么是"pch.h"?为何需要将其作为第一个头文件? [英] What is "pch.h" and why is it needed to be included as the first header file?

查看:2472
本文介绍了什么是"pch.h"?为何需要将其作为第一个头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include "pch.h"
#include <stdio.h>
#include <string.h>

什么是"pch.h"?为什么需要将其作为第一个头文件?

What is "pch.h"? Why is it needed to be included as the first header file?

推荐答案

pch 代表

在计算机编程中,预编译头是(C或C ++)头文件,它被编译为一种中间形式,对于编译器而言,该中间形式的处理速度更快.使用预编译的标头可以显着减少编译时间,尤其是应用于大型标头文件,包含许多其他标头文件的标头文件或包含在许多翻译单元中的标头文件时.

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.

为减少编译时间,某些编译器允许将头文件编译成一种格式,以便编译器更快地处理.这种中间形式称为预编译头,通常保存在扩展名为.pch或类似名称的文件中,例如GNU Compiler Collection下的.gch.

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". (适用于基于控制台的应用程序),但可以使用其他名称,也可以完全不使用.哪个文件将被预编译头(如果有的话)取决于项目设置.

In Visual Studio, precompiled header is usually named "pch.h" (for console based applications), but it is possible to use different name, or not use it at all. Which file would be precompiled header, if any, is determined by projects settings.

如果预编译的头文件是"pch.h",则返回"pch.h".并且编译选项为 /Yu ,Visual Studio将不会在源文件中的#include "pch.h"之前进行任何编译;它假定源代码中直到该行(包括该行)的所有代码均已编译.

If the precompiled header file is "pch.h" and the compile option is /Yu, Visual Studio will not compile anything before the #include "pch.h" in the source file; it assumes all code in the source up to and including that line is already compiled.

这篇关于什么是"pch.h"?为何需要将其作为第一个头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆