Date: Tue, 17 May 2022 10:26:29 -0400
Em ter., 17 de mai. de 2022 às 09:58, Boris Kolpackov via SG15
<sg15_at_[hidden]> escreveu:
> import "header-unit1.hpp"; // Also includes <functional>.
> //
> // But does not "see" any macros defined by
> // the importer, including _GLIBCXX_FUNCTIONAL.
An imported header unit is a different translation unit. It doesn't
see the preprocessor state at the import directive, and it exports all
preprocessor macros. In that particular case, the macro definitions
are "valid redefinitions of the same macro", so it's fine (15.5.7):
"If a macro would be replaced or redefined, and multiple macro
definitions are active for that macro name, the active macro
definitions shall all be valid redefinitions of the same macro (15.6).
[Note: The relative order of pp-imports has no bearing on whether a
particular macro definition is active. — end note]"
As long as the macros came from the same source, they should all just
be "valid redefinitions" and it should all be fine.
daniel
<sg15_at_[hidden]> escreveu:
> import "header-unit1.hpp"; // Also includes <functional>.
> //
> // But does not "see" any macros defined by
> // the importer, including _GLIBCXX_FUNCTIONAL.
An imported header unit is a different translation unit. It doesn't
see the preprocessor state at the import directive, and it exports all
preprocessor macros. In that particular case, the macro definitions
are "valid redefinitions of the same macro", so it's fine (15.5.7):
"If a macro would be replaced or redefined, and multiple macro
definitions are active for that macro name, the active macro
definitions shall all be valid redefinitions of the same macro (15.6).
[Note: The relative order of pp-imports has no bearing on whether a
particular macro definition is active. — end note]"
As long as the macros came from the same source, they should all just
be "valid redefinitions" and it should all be fine.
daniel
Received on 2022-05-17 14:26:41