Here's an example of a struct from the LUFA usb library:
Code: Select all
typedef struct
{
uint32_t Signature; /**< Command block signature, must be \ref MS_CBW_SIGNATURE to indicate a valid Command Block. */
uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper. */
uint32_t DataTransferLength; /**< Length of the optional data portion of the issued command, in bytes. */
uint8_t Flags; /**< Command block flags, indicating command data direction. */
uint8_t LUN; /**< Logical Unit number this command is issued to. */
uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array. */
uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block. */
} ATTR_PACKED MS_CommandBlockWrapper_t;As you can see they have a macro ATTR_PACKED which is defined for each compiler. for gcc:
Code: Select all
#define ATTR_PACKED __attribute__ ((packed))I don't know anything about the other compilers that chibios supports, having never used them, but if they have similar directives for forcing a structure to be packed, could chibios include similar macros?