Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ncr-sd!sagpd1!jharkins From: jharkins@sagpd1.UUCP (Jim Harkins) Newsgroups: comp.lang.c Subject: Re: How many values in an enum (Was: Enumerated types... what's the point?) Message-ID: <714@sagpd1.UUCP> Date: 9 Apr 90 23:19:27 GMT References: <7152@uhccux.uhcc.hawaii.edu> <5152@rtech.rtech.com> <205@caslon.cs.arizona.edu> Reply-To: jharkins@sagpd1.UUCP (Jim Harkins) Organization: Scientific Atlanta, Government Products Div, San Diego, CA Lines: 32 In article <205@caslon.cs.arizona.edu> dave@cs.arizona.edu (David P. Schaumann) writes: -In article <5152@rtech.rtech.com>, mikes@rtech.UUCP (Mike Schilling) writes: -> From article <7152@uhccux.uhcc.hawaii.edu>, by lupton@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@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.