#include <filename> 和有什么区别?和#include“文件名"?

What is the difference between #include lt;filenamegt; and #include quot;filenamequot;?(#include lt;filenamegt; 和有什么区别?和#include“文件名?)
本文介绍了#include <filename> 和有什么区别?和#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?

  1. #include <文件名>
  2. #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 &lt;filename&gt; 和有什么区别?和#include“文件名"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to enforce move semantics when a vector grows?(当向量增长时如何强制执行移动语义?)
Typedef function pointer?(typedef函数指针?)
Reflection and refraction impossible without recursive ray tracing?(没有递归光线追踪就不可能实现反射和折射?)
Is delete[] equal to delete?(delete[] 是否等于删除?)
Why is unsigned integer overflow defined behavior but signed integer overflow isn#39;t?(为什么定义了无符号整数溢出行为但没有定义有符号整数溢出?)
Unions and type-punning(工会和类型双关语)