C enum syntax problem 
Author Message
 C enum syntax problem

Quote:
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" ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Thu, 17 Sep 1992 17:41:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. 'C' enum syntax problem

2. BUG: DEBUG member in enum in class syntax error C2059

3. enum: syntax question

4. enum syntax

5. Newbie: separate big .cs file into small .cs files

6. Problem #30 on http://cs.nmu.edu/programming/c/problems.htm

7. typedef enum as subset of another enum

8. enum - enum ?

9. enum - enum ?

10. Union (not Enum) problem for interfaces (sorry!)

11. Enum problem for interfaces

12. Problem with enum index

 

 
Powered by phpBB® Forum Software