Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #68726
| From | Bo Persson <bo@bo-persson.se> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: upper case enumerator |
| Date | 2019-09-28 10:06 +0200 |
| Message-ID | <gv8il4F4k5aU1@mid.individual.net> (permalink) |
| References | <afea241c-fdd5-485d-89b2-22c402d7e3cb@googlegroups.com> |
On 2019-09-28 at 04:37, 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
>
> [/code]
>
The preprocessor doesn't care about namespaces, it just replaces
everything, everywhere.
One common way to avoid this problem is to reserve all-uppercase
identifiers for the preprocessor, and not use those for anything else.
Bo Persson
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
upper case enumerator Mark <ma740988@gmail.com> - 2019-09-27 19:37 -0700
Re: upper case enumerator Ian Collins <ian-news@hotmail.com> - 2019-09-28 14:43 +1200
Re: upper case enumerator Louis Krupp <lkrupp@nospam.pssw.com.invalid> - 2019-09-27 23:48 -0600
Re: upper case enumerator Bo Persson <bo@bo-persson.se> - 2019-09-28 10:06 +0200
Re: upper case enumerator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-28 21:58 +0100
Re: upper case enumerator Öö Tiib <ootiib@hot.ee> - 2019-09-28 17:10 -0700
Re: upper case enumerator Vir Campestris <vir.campestris@invalid.invalid> - 2019-09-29 21:45 +0100
Re: upper case enumerator Manfred <noname@add.invalid> - 2019-09-29 23:29 +0200
Re: upper case enumerator Ian Collins <ian-news@hotmail.com> - 2019-09-30 16:36 +1300
Re: upper case enumerator Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-09-30 12:25 +0000
Re: upper case enumerator Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-09-30 14:55 +0100
Re: upper case enumerator James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-09-30 01:11 -0400
Re: upper case enumerator Frederick Gotham <cauldwell.thomas@gmail.com> - 2019-09-30 01:34 -0700
csiph-web