- use pragma to handle different behavior between gcc and minGW bit-field packing
- bit-field integer variables needs to be align to 2-byte boundary
Compiler does not produce an error when accessing into non-__packed pointer.
However, the field might not be properly aligned for this type.
More information could be found on:
- https://sourceforge.net/p/mingw-w64/bugs/275/
- http://www.keil.com/support/man/docs/ARMCC/armcc_chr1359124990875.htm
Signed-off-by: Andrej Valek <redacted>
CMD_GET = 0x6b5a
};
-struct __attribute__((__packed__)) h4032l_status_packet {
+struct h4032l_status_packet {
uint32_t magic;
uint32_t values;
uint32_t status;
H4032L_STATUS_TRANSFER,
};
-struct __attribute__((__packed__)) h4032l_trigger {
+#pragma pack(push,2)
+struct h4032l_trigger {
struct {
uint32_t edge_signal:5;
uint32_t edge_type:2;
uint32_t combine_data;
};
-struct __attribute__((__packed__)) h4032l_cmd_pkt {
+struct h4032l_cmd_pkt {
uint16_t magic; /* 0x017f */
uint8_t sample_rate;
struct {
struct h4032l_trigger trigger[2];
uint16_t cmd;
};
+#pragma pack(pop)
struct dev_context {
enum h4032l_status status;