Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!dg!fs06!pds From: pds@lemming.webo.dg.com (Paul D. Smith) Newsgroups: comp.lang.c Subject: Re: question about an array of enum Message-ID: Date: 6 Nov 90 15:07:19 GMT References: <9130019@hpavla.AVO.HP.COM> Sender: news@dg.dg.com Organization: NSDD/ONAD, Data General Corp., Westboro, MA Lines: 37 In-reply-to: gary@hpavla.AVO.HP.COM's message of 5 Nov 90 13:43:22 GMT [] I don't think a compiler can make enums smaller than int and be [] ANSI compliant, since the standard says that enums are ints. K&R II: Section A8.4, p. 215: "The identifiers in an enumerator list are declared as constants of type `int' ... " (sorry, I don't have a copy of ANSI ... ) [] Further, enums don't except the short/long keywords (at least not [] on MSC and HP-UX C). It is for this reason that I almost never use [] enums. Their size varies from machine to machine and there is [] nothing you can do about it. If you *care* about how many bits are in the physical representation of an enum, then you shouldn't be using one. enum's are newfangled (:-) software engineering / data abstraction concepts; their purpose is to represent the type of a variable with a predefined, distinct set of possible values (presumably a smaller set than those representable by an `int'! :-). I admit that I use the actual values of enums sometimes, but I've never had a reason to use a value larger than the size of even a 16-bit integer -- mostly I use them as array indicies when I use the actual value, since my debugger is quite intelligent about enums and handily prints their symbolic value. When I'm not using the actual value I never bother to set it, just to show I don't care. -- paul ----- ------------------------------------------------------------------ | Paul D. Smith | pds@lemming.webo.dg.com | | Data General Corp. | | | Network Services Development | "Pretty Damn S..." | | Open Network Applications Department | | ------------------------------------------------------------------