You cannot have a field starting with an address that is not byte aligned. You expect:
6 bits + 9 bits -> 15 bits -> 2 bytes
but you get:
6 bits -> 1 byte
9 bits -> 2 bytes
total -> 3 bytes
Data is saved as:
| 1 byte | 2 byte |3 byte |
aaaaaaXX bbbbbbbb bXXXXX
when did you expect:
| 1 byte | 2 byte |
aaaaaabb bbbbbbbX
edit: To clarify, based on the comments below:
( struct) . , 9 , union/struct - 16 . , :
struct MyStruct
{
unsigned char a : 6;
union
{
struct
{
unsigned int b : 9;
} c:9;
} d:9;
};
C .