Size of 'enum'
-
I know that the size of enum in VC++ is by default "integral". So the following structure is 4 bytes (or sizeof(int)). I also know that the size will scale based upon the value of said enumeration. However, I need my enum to be 'short' in order to read some binary data into a much larger structure that contains many of these enums? How can I cahnge the size?
typedef enum _ALARM_TYPE
{
LATCHING = 0,
SELF_CLEARING
} ALARM_TYPE;Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
-
I know that the size of enum in VC++ is by default "integral". So the following structure is 4 bytes (or sizeof(int)). I also know that the size will scale based upon the value of said enumeration. However, I need my enum to be 'short' in order to read some binary data into a much larger structure that contains many of these enums? How can I cahnge the size?
typedef enum _ALARM_TYPE
{
LATCHING = 0,
SELF_CLEARING
} ALARM_TYPE;Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
-
Got It, Nevermind.... #pragma enum(2) Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
-
nope, I was wrong.. still looking that was under AIX Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
-
for everyones benefit I am going to post that I have found you cannot change the size of enum under VC++. In some other environments you can. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
Can you do the conversion yourself? By that I mean, if you want the enum to fit into a short then convert it to a short and read/write that. You may need to do some funky casting and/or memcpy'ing, but the effects will be the same and will work on other compilers too