头文件定位规则
当您编写 #include "foo.h"
时,我希望编译器首先检查执行包含操作的文件的目录(而不是当前目录),如果找不到,则回退搜索路径列表,如 #include
的情况。
除非指定了绝对路径,否则#include "/foo.h"
,在这种情况下只需检查绝对路径。
是否存在规则不同的 C 编译器?
When you write #include "foo.h"
I would expect the compiler to check the directory of the file doing the including (as opposed to the current directory) first, and if not found there then fall back on a search of the list of paths as in the case of #include <foo.h>
.
Unless an absolute path was specified, #include "/foo.h"
, in which case only the absolute path needs to be checked.
Are there any C compilers where the rules are different?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
克尼根和里奇写道:
这意味着,不要对报价的搜索策略做出任何假设。然而,我遇到的所有编译器都共享首先在包含文件的路径中搜索的做法,如果找不到,则返回到编译器的搜索路径。
Kernighan & Ritchie write:
Which means, make no assumption on the search strategy for quotes. However, all compilers I have run into share the praxis of searching in the including file's path first, and falling back to the compiler's search path if not found.