gpt4 book ai didi

c++ - 什么是 "pch.h"以及为什么需要将它作为第一个头文件包含在内?

转载 作者:行者123 更新时间:2023-11-28 08:34:58 25 4
gpt4 key购买 nike

#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 中,预编译 header 通常命名为“pch.h”(用于基于控制台的应用程序),但可以使用不同的名称,或者根本不使用它。哪个文件将作为预编译头文件(如果有)由项目设置决定。

如果预编译头文件是“pch.h”并且编译选项是/Yu,Visual Studio 将不会在#include 之前编译任何东西” pch.h" 在源文件中;它假定源代码中直到并包括该行的所有代码都已编译。

关于c++ - 什么是 "pch.h"以及为什么需要将它作为第一个头文件包含在内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59402210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com