Hi All,
If i declare an enum as follows:
typedef enum A
{
a = 0x00000001,
b = 0x00000002
} AObj;
Now if i declare a variable of AObj as follows what does this mean?
AObj myAObj : 2;
Hi All,
If i declare an enum as follows:
typedef enum A
{
a = 0x00000001,
b = 0x00000002
} AObj;
Now if i declare a variable of AObj as follows what does this mean?
AObj myAObj : 2;
It is a way of specifying the number of bits used. That is 2 means 2 bits.
Also note that this is only useful when used with other bit fields in the same struct as alignment and padding will cause the memory to be skipped.
You are probably talking about "bit fields" which enables you to create a struct in which you can address individual bits. But (unless I am mistaken!) your syntax is all wrong: you are missing commas and equals signs in your enum:
typedef enum A
{
a = 0x00000001,
b = 0x00000002
} AObj;
More importantly, bitfields are declared inside of struct
s, so it's not entirely clear what you're trying to do.
(Or is this use of the colon some other syntax I'm not aware of???)