You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The module scan refuses an import inside a preprocessor condition, whatever the condition evaluates to #1026
Split from #421 (§1), which is closed for its other parts.
What happens
An import inside a preprocessor condition is refused by the module scan, whatever the condition evaluates to. Measured with mcpp 2026.11.26.1 (GCC 16.1.0, Linux x86_64):
USE_STD_MODULE is defined nowhere, so the import is not part of the translation unit. The refusal is at src/modgraph/scanner.cppm (if_depth > 0).
Where it was met
扫描器 M1 限制:条件 import 与头单元在移植真实工程时是硬门槛(附一处诊断透传) #421: 17 places in one project (XRGUI), all of one shape: a macro selects between #include in the global module fragment and an import of the same headers; the macro is never defined in the mcpp build.
neargye/magic_enum, module/magic_enum.cppm: #ifdef MAGIC_ENUM_USE_STD_MODULE / import std;. The index package states its scan result with scan_overrides; a project that vendors the upstream file meets the refusal.
[scan_overrides."<glob>"] (docs/04 §2.8.3) is the way out today: the author states the file's scan result.
Direction to evaluate
The scanner's own comment states that it is a second parser of a language whose first parser is the compiler, and that the compiler is right where the two disagree. A condition is the case in which only the compiler has the answer: it depends on defines, on the command line and on the toolchain's built-in macros (__cpp_lib_stacktrace). So the unit's imports would come from the compiler's dependency scan (P1689) when the lexical scan meets an import inside a condition, instead of a refusal — rather than from an evaluation of conditions in the engine, which would be a partial third implementation of the preprocessor.
To settle before an implementation: what the lexical scan is still needed for on such a unit (the provided module name, which precedes any condition the compiler accepts), and the cost of one compiler scan per such unit before the graph is known.
Implemented in mcpp 2026.11.27.1 (#1023). An import inside a preprocessor condition is read by the compiler's dependency scan with the unit's own flags, on GCC and Clang. Header units and MSVC are still refused, and the refusal says why.
Activity
speak-agent commentedon Nov 27, 2026
Implemented in mcpp 2026.11.27.1 (#1023). An
importinside a preprocessor condition is read by the compiler's dependency scan with the unit's own flags, on GCC and Clang. Header units and MSVC are still refused, and the refusal says why.