This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
[Accepted as a DR at the February, 2023 meeting.]
It should be clarified via an example or a note that named module imports do not make macros available.
Proposed resolution (approved by CWG 2023-01-06):
Change in 10.3 [module.import] paragraph 7 as follows:
... These rules can in turn lead to the importation of yet more translation units. [ Note: Such indirect importation does not make macros available, because a translation unit is a sequence of tokens in translation phase 7 (5.2 [lex.phases]). Macros can be made available by directly importing header units as described in 15.5 [cpp.import]. -- end note ]
Add to the example in 15.5 [cpp.import] paragraph 8 as follows:
import "a.h"; // point of definition of #1, #2, and #3, point of undefinition of #1 in "e.h" import "d.h"; // point of definition of #4 and #5 in "e.h" int a = Y; // OK, active macro definitions #2 and #4 are valid redefinitions int c = Z; // error: active macro definitions #3 and #5 are not valid redefinitions of ZModule unit f:export module f; export import "a.h"; int a = Y; // OK
Translation unit #1:import f; int x = Y; // error: Y is neither a defined macro nor a declared name-- end example ]