On 9/27/19 10:37 PM, Mark wrote:
>
> [code]
>
>
> # ifndef XXX_YYY
> # define XXX_YYY
>
> //# pragma once //this is what you should do today and beyond (all things being equal .. compiler support)
> # include <cstddef>
> # include <iostream>
>
> namespace foo
> {
> enum kFavoriteWine { kMoscato, XXX_YYY } ;
> }
>
>
> # endif
>
> auto main() -> int
> {
> using namespace foo ;
> kFavoriteWine xx = XXX_YYY ;
>
> }
> Why does the upper case enumerator collided with the preprocessor macro even though the macro is wrapped in a namespace? Can someone point me to some standard verbiage saying why that's wrong
The key point is that preprocessing (including the expansion of macros)
occurs during translation phase 4 (5.2p4). Namespaces aren't recognized
as such until translation phase 8 (5.2p8), and therefore have no effect
on preprocessing.