How many values in an enum (Was: Enumerated types... what's the point?)

Jim Harkins jharkins at sagpd1.UUCP
Tue Apr 10 09:19:27 AEST 1990


In article <205 at caslon.cs.arizona.edu> dave at cs.arizona.edu (David P. Schaumann) writes:
-In article <5152 at rtech.rtech.com>, mikes at rtech.UUCP (Mike Schilling) writes:
-> From article <7152 at uhccux.uhcc.hawaii.edu>, by lupton at uhccux.uhcc.hawaii.edu (Robert Lupton):
->
->	[ discussion about # elements in an enum deleted ]
-> 
-> 	enum messy = {first=2, second, last=12};
-> 
-
-IMHO IMHO IMHO IMHO IMHO IMHO IMHO IMHO IMHO IMHO IMHO IMHO IMHO IMHO IMHO
-
-I think the practice of giving enum symbols explicit values as above is
-poor programming practice.  If you want a symbol with a specific value,
-you should use either #define first 2 or int first = 2, depending on what
-suits your context.

Oh, I don't know.  Supposing you want to talk to a hardware register.

	enum bit_banger = {foo = 1, bar = 2, baz = 4, last = 0x8000};

Me?  I don't use enums because when I started with C some compilers supported
them, most didn't, and a few even supported them correctly.  Now that they're
in the standard (they are in the standard, aren't they?  I still don't have
K&R 2) I may start using them.  When I do use them I'd like to be able to
do the above, that seems like a real useful feature.


-- 
jim		jharkins at sagpd1

We are all aware of the high cost of alcohol abuse.  To help solve this problem
take this signature to your local liquor store for $1.00 off your next purchase.



More information about the Comp.lang.c mailing list