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

enum is weird

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



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

enum is weird
PostPosted: Tue Aug 03, 2010 6:47 am     Reply with quote

The following code worked well with older v4 compilers:
Code:

typedef enum {SLEEP_FULL,SLEEP_PING} DEVICE_STATE;
DEVICE_STATE DeviceState=SLEEP_FULL;

it fails during compilation in v4.108 with "expecting an identifier" error at "typedef enum {SLEEP_FULL,"

the weird thing is that the following compiles well (_ has been removed in definition but is still used later):
Code:

typedef enum {SLEEPFULL,SLEEP_PING} DEVICE_STATE;
DEVICE_STATE DeviceState=SLEEP_FULL;


why the compiler doesnt like underscore in the first enum item name, and why the compiler uses "SLEEP_FULL" as "SLEEPFULL"

Cheers
Meereck
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Aug 03, 2010 7:21 am     Reply with quote

I suspect you will find that the new compiler has a #define already in existence called 'SLEEP_FULL'. Hence the failure when you use this in the enum. Then when you use 'SLEEP_FULL' in the second line, it is the value of this define, that is being put 'into' the variable, not the first value from your enum. In fact most of the 24, and 33 chips, have such a define, and it is normally '0', so will give the correct first value for the enum, but for the wrong reasons....
Obviously it'd help if you said what chip was involved....

Best Wishes
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Thu Aug 05, 2010 7:31 am     Reply with quote

Hi, thanks for a hint.
Yes, you are right, SLEEP_FULL is defined now in the device header file - 18F2420.h.

Cheers
Meereck
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