"then in the quote directories" 是什么意思?

What do they mean by "then in the quote directories"?

The C Preprocessor version 10.0.1 的第 8 页中,我们有以下声明:

#include "file"

This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>. You can prepend directories to the list of quote directories with the ‘-iquote’ option.

"then in the quote directories" 是什么意思?

gcc 接受几种描述包含目录的命令行参数:

-I - 在 #include <file> 形式的情况下进行搜索,如果其他方法失败

,则在 #include "file" 形式的情况下进行搜索

-iquote - 如果在目录中找不到包含文件的文件,则仅在 #include "file" 形式的情况下搜索。它定义了这些 "quote directories".

文档说:

You can prepend directories to the list of quote directories with the ‘-iquote’ option.

因此,“引用目录”是那些使用“-iquote”选项作为参数传递的目录 1。该选项的文档说:

-iquote dir

Search dir only for header files requested with "#include " file ""; they are not searched for "#include < file >", before all directories specified by -I and before the standard system directories. If dir begins with "=", then the "=" will be replaced by the sysroot prefix; see --sysroot and -isysroot.

1 理论上,来自其他来源。我不知道引用目录的任何其他记录来源;似乎没有记录默认列表。我假设列表默认为空。

C 标准是这样说的:

6.10.2 Source file inclusion
Constraints
A #include directive shall identify a header or source file that can be processed by the implementation.
Semantics
A preprocessing directive of the form

# include <<i>h-char-sequence</i>> <i>new-line</i>

searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the < and > delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined.
A preprocessing directive of the form

# include "<i>q-char-sequence</i>" <i>new-line</i>

causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read

# include <<i>h-char-sequence</i>> <i>new-line</i>

with the identical contained sequence (including > characters, if any) from the original directive.

总之,引用目录是在搜索标准包含路径中的目录之前以实现定义的方式搜索的目录。

根据我的经验,"quote directories" 不是标准术语。相反,这似乎是对那些通过引号形式 #include 而不是通过 angle-bracket 形式搜索的目录的临时描述。它可能源自用于指定可以找到 headers 的目录的命令行选项(在链接文档的第 63-64 页上介绍)。

  • -I dir思考"Include directory"; dir 添加到搜索所有 #include 指令的目录列表中。
  • -isystem dir思考"system include directory"; dir 添加到系统 headers 的目录列表(的前面)。 (这些 headers 传统上 使用 #include 的 angle-bracket 形式,但这不是必需的。)由于系统目录 headers 被两种形式的 #include 搜索,这个选项在很大程度上与 -I 是多余的(或者也许 -I 应该被视为在很大程度上是多余的)。
  • -iquote dir思考"quote include directory"; dir 添加到要搜索的目录列表(最初为空)中 headers 以引用形式 #include 指定。 (这些 headers 传统上 是你写的,但不强制执行。)这些目录不会搜索 angle-bracket 版本。

所以 "quote directories" 是 headers 可以为 #include 的引用形式而不是 angle-bracket 形式存在的目录。通常,不需要这种精度级别,-I 选项就足够了。 (因此不需要 "quote directories" 的标准术语。)