我在 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/