M
mrhicks
Hello all,
I have a question about enumerations. Within some requirements data
passed back a certain bit field is defined by three bits then in
another section the bit field is defined as 4 bits. The second set is
a superset of the first set. The enumeration look as following...
enum SET1 { AutoOffState = 0x00, AutoOneState = 0x01,
TrippedOffState = 0x02, TrippedOnState = 0x03,
LockedOffState = 0x04, LockedOnState = 0x05,
CollardOffState = 0x06, CollardOnState = 0x07
};
enum SET2 { AutoOffState = 0x00, AutoOneState = 0x01,
TrippedOffState = 0x02, TrippedOnState = 0x03,
LockedOffState = 0x04, LockedOnState = 0x05,
CollardOffState = 0x06, CollardOnState = 0x07,
NoComm = 0x09, SwitchFault = 0x0A,
NotInstalled = 0x0B
};
Note: I know the names with the enumeration can not be the same as
it will generate a compile error.
There are a lot of returned data bit fields that are similar, but
the values are the same. I was wondering if there is some way to
include a perviously defined enumeration within another enumeration
like
enum SET2 { enum SET1,
NoComm = 0x09, SwitchFault = 0x0A,
NotInstalled = 0x0B
};
But this does work. I also tried the following
enum SET2 { AutoOffState, AutoOneState,
TrippedOffState, TrippedOnState,
LockedOffState, LockedOnState,
CollardOffState, CollardOnState,
NoComm = 0x09, SwitchFault = 0x0A,
NotInstalled = 0x0B
};
But this will not work either as the names will collide and generate
a compile error. Is there a clean way of adding an already defined
enumeration within another enumeration declaration? What is the best
way to handle this? I am just trying to reduce errors and tpying as I
have a lot of fields that overlap. Yes, cut and paste works great, but
if the value changes I would like it to propagate down if possible.
Thanks!!!
Mark
I have a question about enumerations. Within some requirements data
passed back a certain bit field is defined by three bits then in
another section the bit field is defined as 4 bits. The second set is
a superset of the first set. The enumeration look as following...
enum SET1 { AutoOffState = 0x00, AutoOneState = 0x01,
TrippedOffState = 0x02, TrippedOnState = 0x03,
LockedOffState = 0x04, LockedOnState = 0x05,
CollardOffState = 0x06, CollardOnState = 0x07
};
enum SET2 { AutoOffState = 0x00, AutoOneState = 0x01,
TrippedOffState = 0x02, TrippedOnState = 0x03,
LockedOffState = 0x04, LockedOnState = 0x05,
CollardOffState = 0x06, CollardOnState = 0x07,
NoComm = 0x09, SwitchFault = 0x0A,
NotInstalled = 0x0B
};
Note: I know the names with the enumeration can not be the same as
it will generate a compile error.
There are a lot of returned data bit fields that are similar, but
the values are the same. I was wondering if there is some way to
include a perviously defined enumeration within another enumeration
like
enum SET2 { enum SET1,
NoComm = 0x09, SwitchFault = 0x0A,
NotInstalled = 0x0B
};
But this does work. I also tried the following
enum SET2 { AutoOffState, AutoOneState,
TrippedOffState, TrippedOnState,
LockedOffState, LockedOnState,
CollardOffState, CollardOnState,
NoComm = 0x09, SwitchFault = 0x0A,
NotInstalled = 0x0B
};
But this will not work either as the names will collide and generate
a compile error. Is there a clean way of adding an already defined
enumeration within another enumeration declaration? What is the best
way to handle this? I am just trying to reduce errors and tpying as I
have a lot of fields that overlap. Yes, cut and paste works great, but
if the value changes I would like it to propagate down if possible.
Thanks!!!
Mark