Hello there,
I am trying to force my 32 bit system to align my struct with bytes not words...
This is my struct:
Code:
typedef struct
{
uint8_t tolerance;
uint8_t footprint[24];
uint8_t value[24];
uint8_t comment[100];
uint8_t type[24];
uint8_t pitch;
uint8_t rotation;
} fppStruct_t;
typedef union
{
fppStruct_t fppStruct;
uint8_t fppArray[sizeof(fppStruct_t)]; // 175
} feederPartParam_t;
I am using __packed=__attribute__((__packed__)) in symbols.
When I do:
Code:
(sizeof(feederPartParam_t)
I get 175 like i thought I would (1+24+24+100+24+1+1).
But when I do (feeder is an object of type feederPartParam*):
Code:
feeder->fPartParams.fppStruct.tolerance = 10;
feeder->fPartParams.fppStruct.footprint[0] = 1;
I thought my array would get populated like this:
Code:
feeder->fPartParams.fppStruct.fppArray[0] = 10;
feeder->fPartParams.fppStruct.fppArray[1] = 1;
feeder->fPartParams.fppStruct.fppArray[2] = 0;
...
Instead I get some weird padding:
Code:
feeder->fPartParams.fppStruct.fppArray[0] = 10;
feeder->fPartParams.fppStruct.fppArray[1] = 0;
feeder->fPartParams.fppStruct.fppArray[2] = 1;
...
It skips one byte. Is there a way to make the padding one byte? I dont quite understand because the struct size is correct but padding is wrong. I would apreciate all help!