C++ header 单元导入语法

C++ header unit importation syntax

在当前的 C++ 草案(2019 年 8 月)中,pp-import http://eel.is/c++draft/cpp.import#nt:pp-import) 的语法允许在 header-name 或 [=14] 之后附加 pp-tokens =].

该部分的当前版本是 P1703: "Recognizing Header Unit Imports Requires Full Preprocessing". Before the changes caused by this proposal, the grammar still allowed for preprocessing tokens tokens after the header-name or the header-name-tokens, but in the form of a pp-import-suffix. (section [cpp.module] of P1103) 的结果。

在此上下文中允许额外的、未使用的预处理令牌背后的原因是什么?

谢谢。

他们在那里允许属性。

第 7 阶段(语法分析和语义分析)语法没有改变。导入仍然允许使用属性。以前,阶段 4(预处理器)语法试图限制更多允许作为导入的内容,以强制执行以下规则:

A pp-import is only recognized when the sequence of tokens produced by phase 4 of translation up to the import token forms an import-seq, and the import token is not within the header-name-tokens or pp- import-suffix of another pp-import.

新规则进一步限制了它,不允许每行导入多个,因此不再需要这条规则及其相关语法。