首页 > 解决方案 > Include file on different compilers

问题描述

Will

#include "filename"

always search for a file in standard include directory if not found in the current directory or for some compilers may not?

Is it possible to turn off searching for the file in standard include directories using this directive for example for gcc?

标签: c++

解决方案


§[cpp.incluce]/2:

形式的预处理指令

# 包含“ q-char-sequence 换行符

导致将该指令替换为由 " 分隔符之间的指定序列标识的源文件的全部内容。以实现定义的方式搜索命名的源文件。如果不支持此搜索,或者搜索失败, 该指令被重新处理,就好像它读取

# 包含 < h-char-sequence > 换行符

与原始指令中相同的包含序列(包括>字符,如果有的话)。

...所以是的,如果它没有找到它,它总是在标准包含目录中重新搜索。


推荐阅读