Closed Laeeth closed 4 years ago
I scratched my head as to why this was happening since dpp no longer translates literal macros as actual macros but as D enums. The reason is that linux
is one of the built-in macros in clang on Linux and so is never seen by dpp. Even if it were, there's no way to stop the preprocessor from then replacing the enum's name when it runs.
preprocessor macros should not be applied to module and import D statements
This isn't possible. dpp doesn't (and can't) know anything about module or import statements. Or any D statements at all. The preprocessor can't either, all it seens are tokens.
obvious potentially dangerous side-effects if other macros should refer to the symbol.
That would be extremely unlikely. The most likely case for linux
showing up anywhere would be in an ifdef
or ifndef
, by which point everything has been properly preprocessed.
I think the workaround is good enough, and that without it, the behaviour is consistent with what it would be in C++ (i.e. trying to name a C++20 module linux
would fail as well), which is the goal of dpp.
Example.
will try to flesh out a little shortly.
workaround but with obvious potentially dangerous side-effects if other macros should refer to the symbol.