`?-6ren"> `?-来自 here ,据说: For #include "filename" the preprocessor searches in the same directory as the file con-6ren">
gpt4 book ai didi

c++ - 为什么我们使用 `#include "stdafx.h "` instead of ` #include `?

转载 作者:可可西里 更新时间:2023-11-01 17:36:47 28 4
gpt4 key购买 nike

来自 here ,据说:

For #include "filename" the preprocessor searches in the same directory as the file containing the directive. This method is normally used to include programmer-defined header files.

For #include <filename> the preprocessor searches in an implementation dependent manner, normally in search directories pre-designated by the compiler/IDE. This method is normally used to include standard library header files.

同时 this wiki link建议 stdafx.h是由 visual studio IDE 预先设计的头文件

stdafx.h is a file, generated by Microsoft Visual Studio IDE wizards, that describes both standard system and project specific include files that are used frequently but hardly ever change.

Compatible compilers (for example, Visual C++ 6.0 and newer) will precompile this file to reduce overall compile times. Visual C++ will not compile anything before the #include "stdafx.h" in the source file, unless the compile option /Yu'stdafx.h' is unchecked (by default); it assumes all code in the source up to and including that line is already compiled.

The AFX in stdafx.h stands for Application Framework eXtensions. AFX was the original abbreviation for the Microsoft Foundation Classes (MFC). While the name stdafx.h is used by default, projects may specify an alternative name.

然后

为什么我们使用#include "stdafx.h"而不是 #include <stdafx.h> ?

最佳答案

A stdafx.h , stdafx.cpp pair 由 VS 从模板生成。它位于其余文件所在的同一目录中。您可能最终会专门为您的项目更改它。所以我们使用 ""而不是 <>正是因为它与您的第一句话描述的目录位于同一目录中。

关于c++ - 为什么我们使用 `#include "stdafx.h "` instead of ` #include <stdafx.h>`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37257725/

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