#include <filename>
和之间的区别#include "filename"
是特定于编译器实现的(#include <filename>和#include“ filename”之间的区别是什么?)。GCC对此的实现已被详细记录(http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html)。对于Visual C ++,存在类似的文档。
使用LLVM / Clang编译时对应的规则是什么?即,在使用每种语法时Clang会首先出现在哪里和/或不在哪里出现?
在文档中找不到任何可以指定每种情况下预期行为的内容,因此我很好奇并决定查看此处的代码。假设这是始终存在的行为可能是错误的,但是如果没有文档,我认为源代码是次要的事情。
搜索代码后,我发现在这里在方法中#include
处理了编译指示(第453行),在该处确定是否包含(第468行),然后将该值用作方法的参数(第477行)。HandlePragmaDependency
isAngled
LookupFile()
此方法在HeaderSearch.cpp(第498行)中定义,文档注释指出:
[...] isAngled指示文件引用是否适用于系统#include的引用(即,使用<>代替“”)。[...]
在该方法的后面,isAngled
在三个地方(第547、596和673行)中使用的值,每个地方都有以下注释。
// Unless disabled, check to see if the file is in the #includer's
// directory. This cannot be based on CurDir, because each includer could be
// a #include of a subdirectory (#include "foo/bar.h") and a subsequent
// include of "baz.h" should resolve to "whatever/foo/baz.h".
// This search is not done for <> headers.
if (!Includers.empty() && !isAngled && !NoCurDirSearch) {
...
// If this is a system #include, ignore the user #include locs.
unsigned i = isAngled ? AngledDirIdx : 0;
...
// If we are including a file with a quoted include "foo.h" from inside
// a header in a framework that is currently being built, and we couldn't
// resolve "foo.h" any other way, change the include to <Foo/foo.h>, where
// "Foo" is the name of the framework in which the including header was found.
if (!Includers.empty() && !isAngled &&
Filename.find('/') == StringRef::npos) {
希望能帮助到你。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句