How does the GNU compiler allocate bit fields !
I am trying to decode a message that is defined as follows
Parameter No of bits
A 8
B 6
C 210 ( 253 bits - various configurations )
W 2
X 24
Y 1
Z 5
Total of 256 bits
I have found that the following works (a least to extract the B field)
typedef struct GEN_ts_tag
{
unsigned A :8;
AAAAAAAA
unsigned C1 :2;
unsigned B :6;
BBBBBBCC
unsigned C2 :16; // - 32 bits so far
CCCCCCCC
CCCCCCCC
unsigned C3[6]; // - 192 more bits
CCCCCCCC …
unsigned W :2;
XXXXXXWW
unsigned X1 :6;
XXXXXXXX
unsigned X :18;
XXXXXXXX
unsigned Y :1;
unsigned Z :5;
XXXYZZZZZ
} GEN_ts;
typedef GEN_ts * pGEN_ts;
I expected to be able to assign the fields as follows
typedef struct GEN_ts_tag
{
unsigned A :8;
unsigned B :6;
unsigned C1 :18; // - 32 bits so far
unsigned C[6]; // - 192 more bits
unsigned W :2;
unsigned X :24;
unsigned Y :1;
unsigned Z :5;
} GEN_ts;
typedef GEN_ts * pGEN_ts;
I realize that I have some sort of endian mental block.