Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
174 views
in Technique[技术] by (71.8m points)

c++ - #include和有什么不一样 <filename> 和#include“文件名”?(What is the difference between #include <filename> and #include “filename”?)

在C和C ++编程语言中,在include语句中使用尖括号和引号有什么区别,如下所示?

  1. #include <filename>
  2. #include "filename"
  ask by quest49 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In practice, the difference is in the location where the preprocessor searches for the included file.

(实际上,区别在于预处理器搜索包含文件的位置。)

For #include <filename> the preprocessor searches in an implementation dependent manner, normally in search directories pre-designated by the compiler/IDE.

(对于#include <filename> ,预处理器通常以实现依赖方式进行搜索,通常在编译器/ IDE预先指定的搜索目录中进行搜索。)

This method is normally used to include standard library header files.

(此方法通常用于包括标准库头文件。)

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.

(对于#include "filename" ,预处理器首先在与包含指令的文件相同的目录中搜索,然后遵循用于#include <filename>格式的搜索路径。)

This method is normally used to include programmer-defined header files.

(此方法通常用于包括程序员定义的头文件。)

A more complete description is available in the GCC documentation on search paths .

(有关搜索路径的GCC 文档中提供了更完整的描述。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...