AnsweredAssumed Answered

bit fields with pragma packed still generates pad nibbles in 16 bit case.

Question asked by Leong on Apr 12, 2013
Latest reply on Apr 19, 2013 by Leong



I'm using CW7.1 for codefire 5225x to generate some byte streams. in the definition document, it asks for 2 consecutive 12 bit numbers that takes 3 bytes. so i used the code below (simplified) but it seems the sizeof is 4 bytes instead of 3. if I assign foo and bar with 0x1111, they show up in the stream as 0x1110, which means a padding nibble is added to each var..


any recommendations other than split the 2 vars into 2 int8 + 2 nibbles?


#pragma options align=packed

typedef struct


  int16_t     foo:12 ;       

  int16_t     bar:12 ;




thanks in advance.