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!
Presume you are running a processor requiring word allocation at even addresses. It will possibly fill up the structure to even byte size. The structure size actually matters when arranging it in larger structs or arrays. You can use "pack" pragma to allocate it differently, but possibly can't access the unt16 objects directly any more.
I'm running the program on an Intel i7 4700mq and MinGW-GCC v 4.8.1 toolchain under Eclipse IDE but I think I will use the defined struct also on Arduino Mega2560.
Are this sizes depending both by the architecture and by the compiler used?
Anyway, with a different example, the size appears to be correct: