Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.lang.c Subject: Re: 'C' enum syntax problem Keywords: enum syntax Message-ID: <1503@auspex.auspex.com> Date: 25 Apr 89 18:23:11 GMT References: <1095@cvbnet2.UUCP> Reply-To: guy@auspex.auspex.com (Guy Harris) Distribution: usa Organization: Auspex Systems, Santa Clara Lines: 47 >Does it mean that subsets of an enum cannot be defined ? It means that the names of enumeration members are global, not local to the "enum" in which they're used; this means that you can't have the same "enum" name belong to two different enumerations (at least not with different values) within the same scope. Since C has no notion of a subrange type, and since you seem to be trying to create a subrange type of WEEK, the answer is basically "no, subranges of an enum cannot be defined." >Is this a bug in my C Compiler ? No. It is doing the correct thing. >What does PAns say about this ? 3.5.2.2 Enumeration specifiers ... Semantics The identifiers in an enumerator list are declared as constants that have type "int" and may apper wherever such are 58 permitted. ... 58. Thus, the identifiers of enumeration constants declared in the same scope shall all be distinct from each other and from other identifiers declared in ordinary declarators. >Is there a work around ? typedef enum WEEK { WEEK_MONDAY, WEEK_TUESDAY, WEEK_WEDNESDAY, WEEK_THURSDAY, WEEK_FRIDAY, WEEK_SATURDAY, WEEK_SUNDAY }; typedef enum WEEK_END { WEEK_END_SATURDAY, WEEK_END_SUNDAY }; is one possibility.