Difference between angle bracket < > and double quotes “ ” while including header files in C++?
Possible Duplicate:
What is the difference between #includeand #include"filename"?
角括号EDOCX1 0和双引号EDOCX1?1的区别是什么,其中包括头文件在C++中?
我的意思是,哪些文件应该使用
它依赖于编译器。也就是说,通常使用
A preprocessing directive of the form
1 # include <h-char-sequence> new-linesearches 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
1 # include"q-char-sequence" new-linecauses 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
1 # include <h-char-sequence> new-linewith the identical contained sequence (including
> characters, if any) from the original
directive.
因此,在大多数编译器中,使用
使用尖括号时,编译器将在包含路径列表中搜索文件。当使用双引号时,它首先搜索当前目录(即正在编译的模块所在的目录),然后才搜索包含路径列表。
因此,按照惯例,您可以使用标准include的尖括号和其他所有内容的双引号。这样可以确保在(不推荐)情况下,如果您有一个与标准头同名的本地头,那么在每个情况下都会选择正确的头。