View previous topic :: View next topic |
Author |
Message |
dtemplar
Joined: 16 Feb 2004 Posts: 5
|
Help! "Too many elements in an ENUM" |
Posted: Wed Feb 18, 2004 9:20 pm |
|
|
Code: |
enum TIMER_CONSTANTS
{
TMR1_200us = 0xFC17,
TMR1_100us = 0xFE0B,
FRC_FAST = TMR1_100us,
FRC_SUM = 1,
TMR0_5mSEC = 0xF3C9,
GEN_1SEC = 200,
T_1SEC = GEN_1SEC,
T_50mSEC = 10,
T_1OOmSEC = 20,
};
|
Why does this code generate the "Too many elements in an ENUM" error?
I don't understand. |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Wed Feb 18, 2004 9:40 pm |
|
|
TMR1_100us = 0xFE0B,
FRC_FAST = TMR1_100us,
How can one element have the value of the name of another element? |
|
|
dtemplar
Joined: 16 Feb 2004 Posts: 5
|
|
Posted: Wed Feb 18, 2004 11:06 pm |
|
|
This is actually a code from a program designed for MCC18 compiler.
Here's the last thing i tried, i removed the comma after the last element and replaced the assigned 16-bit constants (0xFC17, 0xFE0B...) with 8-bit 0x01 and it compiled successfully. It must have problems with enum constants greater than 8-bits. but:
"The id after ENUM is created as a type large enough to the largest constant in the list. The ids in the list are each created as a constant."
(p. 64, CCS C reference manual)
I must have missed something. :( |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Thu Feb 19, 2004 8:38 am |
|
|
dtemplar wrote: | This is actually a code from a program designed for MCC18 compiler.
Here's the last thing i tried, i removed the comma after the last element and replaced the assigned 16-bit constants (0xFC17, 0xFE0B...) with 8-bit 0x01 and it compiled successfully.
|
A constant name cannot be a name of an element.
For example, this is bad:
Code: |
#define RED=1
/*code*/
enum CODES {RED=5, BLUE=3,GREEN=2};
|
|
|
|
|