[comp.lang.c] C enum syntax problem

dmg@ssc-vax.UUCP (David Geary) (04/26/89)

Krishna writes:
: I seem to have some problem in using the enum construct on Sun-3
: m/c.
: The following declarations generate an error.
: 
:    typedef enum WEEK {
:      MONDAY, TUESDAY, WEDNESDAY,
:      THURSDAY, FRIDAY,
:      SATURDAY, SUNDAY
:    } ;
:    typedef enum WEEK_END {
:      SATURDAY, SUNDAY
:    } ;
: 
: The error messages are
: 	redeclaration of SATURDAY
: 	redeclaration of SUNDAY

: Does it mean that subsets of an enum cannot be defined ?

  Yes.  K&RvII, pg 215:  

  "Enumerations are unique types with values ranging over
a set of named constants called enumerators...  Enumerator
names in the same scope must all be distinct from each
other and from ordinary variable names, but the values
need not be distinct."

: Is this a bug in my C Compiler ?

  No.

: Is there a work around ?

  Of course ;-)

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ David Geary, Boeing Aerospace, Seattle                 ~ 
~ "I wish I lived where it *only* rains 364 days a year" ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~