尖括号℃之间的差异; >和双引号" "而包括C ++头文件? [英] Difference between angle bracket < > and double quotes " " while including header files in C++?

查看:112
本文介绍了尖括号℃之间的差异; >和双引号" "而包括C ++头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename\">What是的#include℃之间的差;文件名&GT;和#包括文件名?

什么是尖括号之间的差异&LT; &GT; 和双引号而包括C头文件++

What is the difference between angle bracket < > and double quotes " " while including header files in C++?

我的意思是哪些文件应该使用例如包括:的#include&LT; QPushButton&GT; 和哪些文件例如使用包括: #包括MyFile.h ???

I mean which files are supposed to be included using eg: #include <QPushButton> and which files are to be included using eg: #include "MyFile.h"???

推荐答案

这是编译器的依赖。这就是说,在一般使用在系统头优先在当前工作目录标题&LT;&GT; 通常是用于系统头从该规范(第6.10.2):

It's compiler dependent. That said, in general using " prioritizes headers in the current working directory over system headers. <> usually is used for system headers. From to the specification (Section 6.10.2):

形式的preprocessing指令

A preprocessing directive of the form

  # include <h-char-sequence> new-line


  
  

搜索的实现定义的名额序列由℃至指定序列唯一标识的头; &GT; 分隔符,并且使得由标题的全部内容的替代品,指令。地方是如何规定或标识的标头是实现定义的。

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.

形式的preprocessing指令

A preprocessing directive of the form

  # include "q-char-sequence" new-line


  
  

通过由定界符之间的指定序列所标识的源文件的全部内容导致更换该指令的该命名的源文件中搜索在一个实施-defined方式进行。如果不支持此搜索,如果搜索失败,该指令,如果它再加工读

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


  
  

与含有相同序列(包括&GT; 字符,如果有的话)从原来的
  指示。

with the identical contained sequence (including > characters, if any) from the original directive.

于是就的的编译器,使用首先检查你的本地目录,如果没有找到匹配,那么在移动检查系统路径。使用&LT;方式&gt; 与系统头开始搜索

So on most compilers, using the "" first checks your local directory, and if it doesn't find a match then moves on to check the system paths. Using <> starts the search with system headers.

这篇关于尖括号℃之间的差异; &GT;和双引号&QUOT; &QUOT;而包括C ++头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆