What is the difference between #include lt;filenamegt; and #include quot;filenamequot;?(#include lt;filenamegt; 和有什么区别?和#include“文件名?)
问题描述
在C和C++编程语言中,include语句中使用尖括号和使用引号有什么区别,如下?
In the C and C++ programming languages, what is the difference between using angle brackets and using quotes in an include statement, as follows?
#include <文件名>#include "文件名"
推荐答案
实际上,区别在于预处理器搜索包含文件的位置.
In practice, the difference is in the location where the preprocessor searches for the included file.
对于#include <filename>,预处理器以与实现相关的方式搜索,通常在编译器/IDE 预先指定的搜索目录中.该方法通常用于包含标准库头文件.
For #include <filename> the preprocessor searches in an implementation dependent manner, normally in search directories pre-designated by the compiler/IDE. This method is normally used to include standard library header files.
对于#include "filename",预处理器首先在与包含指令的文件相同的目录中搜索,然后按照用于#include <filename>代码>形式.此方法通常用于包含程序员定义的头文件.
For #include "filename" the preprocessor searches first in the same directory as the file containing the directive, and then follows the search path used for the #include <filename> form. This method is normally used to include programmer-defined header files.
在 GCC 搜索路径文档.
这篇关于#include <filename> 和有什么区别?和#include“文件名"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:#include <filename> 和有什么区别?和#include“文件名"?
基础教程推荐
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
