This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Struct Packing

Hello,

I'm having some problems with the generic CC3000 driver.

I am using a processor that has a 16 bit memory access. Because of this, any 16 bit value (like an unsigned short) must be aligned to a 16 bit address.

For instance this struct is 4 bytes, 2 chars, and 1 short. But my compiler must align the short to a 16 bit address. It also pads out a struct to even number of bytes.

So, for me, this struct is sizeof 6.  This really seems to make everything not work. I don't think I can get my compiler to pack the struct do to the HW design.

Has anyone reworked the code to avoid "sizeof"?

typedef struct _hci_cmnd_hdr_t

{

     unsigned char  ucType;

     unsigned short usOpcode;

     unsigned char  ucLength;

 } hci_cmnd_hdr_t;

 

Thanks,

Tim