有什么区别?-6ren"> 有什么区别?-我在 Visual Studio 2010 中工作。我在 Project Properties -> Linker -> General -> Additional Directories 添加了一个-6ren">
gpt4 book ai didi

c++ - include "file.h"vs 有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:54:27 25 4
gpt4 key购买 nike

我在 Visual Studio 2010 中工作。我在 Project Properties -> Linker -> General -> Additional Directories 添加了一个目录

如果我使用项目编译

 "file.h"

但如果我使用则不会

 <file>

最佳答案

您可能假设 < >隐式添加 .h到文件名的末尾。这不是真的。你是否使用< >" "对文件名没有意义。它基本上告诉实现应该以何种顺序遍历包含目录以查找头文件。

引用标准:

A preprocessing directive of the form
# include <h-char-sequence> new-line
searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the < and > delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined.

A preprocessing directive of the form
# include "q-char-sequence" new-line
causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read

# include <h-char-sequence> new-line
with the identical contained sequence (including > characters, if any) from the original directive

关于c++ - include "file.h"vs <file> 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8160089/

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