Achso, ja, das packed hab ich drin:
Code:
/* the User preset range in the EEPROM was fixed to 16 Bytes */
/* these paramters can changed by the user in normal operation mode */
#pragma pack(1) /* align the structure to bytes to minimize size */
typedef struct
{
U16 last_P10_pre; /* last user Pressure for PRE-Insufflation */
U16 last_Q10_pre; /* last user Flow for PRE-Insufflation */
U16 last_P10_main; /* last user Pressure for MAIN-Insufflation */
U16 last_Q10_main; /* last user Flow for MAIN-Insufflation */
BOOL last_Video; /* last user Video on/Off state */
U8 reserved1;
U16 reserved2;
U16 reserved3;
U16 checksum; /* CRC16 */
} t_user_data;
#pragma pack() /* end of packed structure */
hier "dürfte" es also keine Lücken geben, der Compiler "sollte" es Byteweise ablegen.
ohne das packed, wäre es gut möglich, dass er es auf die Standardbreite eines int aligned.
Probier ich gleich mal....
- - - Aktualisiert - - -
ich hab das grad mal probiert:
Code:
//#pragma pack(1) /* align the structure to bytes */
typedef struct
{
short a;
char b;
short c;
} t_my_data;
//#pragma pack() /* end of packed structure */
o = offsetof(t_my_data,c);
jo, hier verschiebt sich der Offset um 1 Byte
der Offset zu "c" ist unpacked = 4 bei packed = 3
der GNU-ARM Compiler macht das als richtig.
Lesezeichen