This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compiling GCC with g++: a report


On Mon, 23 May 2005 23:25:13 -0700, Mark Mitchell <mark@codesourcery.com> wrote:

> Good point; yes, you would have to pass a pointer.  I guess you could
> create a singleton representative of each value in the enum, and pass
> them around, but I agree that's getting pretty ugly.  Of course, the
> problem with "unsigned int" is that it is a complete type, and people can
> accidentally pass in "7", even if there's no such enumeral.  You really
> want forward-declared enums, but you haven't got them; it may be you just
> lose. :-(

You don't have foward-declared enums because you don't know how large they
need to be.

If what you want is an opaque enum, such that other files treat it as an
integer and only certain files know the enumerators, then declare your
variables to some typedef of an integer.  People could accidentally pass in
"7" anyway in C.  You either get the opacity or the type checking (when
compiled as C++), but not both.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]