Lucast85
Member level 3
Hi all,
I'm doing some experiments to learn the bitfiled concept. I start with an example, but the size of the struct returned is not as much as i expected.
In fact, the program return that the size of such a structure is 4 bytes. I expect a size of 3 bytes because I used bitfield.
Maybe I'm missing something. What?
Thank you!
I'm doing some experiments to learn the bitfiled concept. I start with an example, but the size of the struct returned is not as much as i expected.
Code:
typedef struct{
uint16_t field1;
uint8_t field2 : 7;
uint8_t field3 : 1;
}MyStruct_t;
MyStruct_t aStruct;
printf("Size of aStruct= %d\n", sizeof(aStruct));
Maybe I'm missing something. What?
Thank you!