Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!bloom-beacon!daemon From: scs@adam.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: question about an array of enum Message-ID: <1990Nov8.000847.16340@athena.mit.edu> Date: 8 Nov 90 00:08:47 GMT References: <9130019@hpavla.AVO.HP.COM> <1990Nov7.003126.23445@zoo.toronto.edu> Sender: daemon@athena.mit.edu (Mr Background) Reply-To: scs@adam.mit.edu (Steve Summit) Organization: Thermal Technologies, Inc. Lines: 25 In article <1990Nov7.003126.23445@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes: >...each [enum] is "compatible with an integer >type; the choice of type is implementation-defined"... >So an implementation could easily decide that `enum { f=0, t=1 }' >is represented as `char' rather than `int'. I think this has been discussed before, perhaps on comp.std.c . (I do hope it hasn't been discussed much, or recently. I can't remember the consensus, but it would be particularly embarrassing for me to ask a frequently-asked question :-) .) Does the standard really allow a different choice to be made for different enumerations? Henry's word "each" (which also appears in the standard, section 3.5.2.2) is interesting, and might suggest that different sizes are legal, but Appendix F.3.9 (which is, to be sure, not part of the formal Standard) notes as implementation- defined "the integer type chosen to represent the values of an enumeration type." If different enums can have different sizes (which seems like a useful license to grant the compiler) the documentation would have to state "the algorithm by which the integral types for enumerations are chosen," not "the [single] integral type." Steve Summit scs@adam.mit.edu