View previous topic :: View next topic |
Author |
Message |
meereck
Joined: 09 Nov 2006 Posts: 173
|
enum is weird |
Posted: Tue Aug 03, 2010 6:47 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19378
|
|
Posted: Tue Aug 03, 2010 7:21 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
meereck
Joined: 09 Nov 2006 Posts: 173
|
|
Posted: Thu Aug 05, 2010 7:31 am |
|
|
Hi, thanks for a hint.
Yes, you are right, SLEEP_FULL is defined now in the device header file - 18F2420.h.
Cheers
Meereck |
|
![](templates/subSilver/images/spacer.gif) |
|