[C++-sig] Re: Re: Wrapping #define's and anonymous enum's

Mike Rovner mike at bindkey.com
Fri Dec 13 00:31:48 CET 2002


"David Abrahams" <dave at boost-consulting.com> wrote in message
news:u1y4nndkj.fsf at boost-consulting.com...

> >> #define MSG_A 23
> >> #define MSG_B 25
> >> enum {Red, White, Blue = 40 };
> >>
> >> What would the boost wrapper code for the above look like?
> >
> >   #include <boost/python.hpp>
> >
> >   BOOST_PYTHON_MODULE(my_module)
> >   {
> >     scope().attr("MSG_A") = 23;
> >     scope().attr("MSG_B") = 25;
> >     scope().attr("Red") = 0;
> >    ...
> >   }
> >
> > But you really DON'T WANT to do this.
> > Think twice about your code.
>
> Why not, Mike?

IMHO anonimous enums and especialy #define's are marks of a design style I
personaly tend to avoid ;)
Clattering (global) namespace and unusable at debug time names are
definitely not Good Things.

So I usualy write a tiny C++ wrapper around a library I can't change to
avoid and enlight such things.
Just to make my future life easyer. :)

> But of course, you have to have a name for the enum type to do that.
Exactly.








More information about the Cplusplus-sig mailing list