CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help! "Too many elements in an ENUM"

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dtemplar



Joined: 16 Feb 2004
Posts: 5

View user's profile Send private message

Help! "Too many elements in an ENUM"
PostPosted: Wed Feb 18, 2004 9:20 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 18, 2004 9:40 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 18, 2004 11:06 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 19, 2004 8:38 am     Reply with quote

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};
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group