<xkeycheck.h>: Fix circular inclusion for Header Units #1692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Works towards #60.
Discovered by @olgaark - we've done something weird in the machinery that detects macroized keywords, and this is a problem for building Standard Library Header Units.
We had correctly marked
xkeycheck.has not being automatically importable as a header unit:STL/stl/inc/header-units.json
Line 126 in 3c13e3e
And correctly marked
yvals_core.h(the STL's central internal header) as being importable (like the vast majority of STL headers):STL/stl/inc/header-units.json
Line 148 in 3c13e3e
Next,
yvals_core.hdefines_STL_COMPILER_PREPROCESSOR:STL/stl/inc/yvals_core.h
Lines 9 to 18 in 3c13e3e
And includes
vcruntime.hfor_HAS_CXX17etc. before includingxkeycheck.h:STL/stl/inc/yvals_core.h
Lines 341 to 342 in 3c13e3e
🪲 Finally, because
xkeycheck.hwants_STL_COMPILER_PREPROCESSORand_HAS_CXX17etc. it includesyvals_core.h, which is circular inclusion!STL/stl/inc/xkeycheck.h
Lines 6 to 10 in 3c13e3e
This wasn't causing problems for ordinary compilation (because
yvals_core.h's#pragma onceand include guards prevent the recursion), but attempting to build STL Header Units in an optimal way involves "source dependencies" scanning, and this makesyvals_core.hlook like it includes itself, which is a problem.The fix is simple: remove the circular inclusion, and simply comment that
xkeycheck.his super special. Nothing else in the STL includes it, and users should not be including it directly. (I vaguely recall that at one time, every STL header tried to includexkeycheck.hitself, but we centralized this long ago.)