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

标签 c++ c visual-studio-2010 include

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

相关文章:

C、从文本文件中读取 double 值

visual-studio-2010 - 在源代码管理中查找 --> Visual Studio 2010 中的状态选项未显示

c++ - 在类定义中使用 'this'

c++ - 检查 time_t 是否在其他 time_t 之间并有一定误差

c++ - Vector<char*> push_back 覆盖所有条目

C中的Python实例方法

c++ - Win32 GDI 画一个圆?

c++ - 互斥锁示例/教程?

windows - ffmpeg avformat_open_input 总是返回 "Protocol not found"rv=(-1330794744)

vb.net - 使用Visual Studio的ArcGIS 10.2调试