Thomas Martitz wrote:
Try appending __attribute__((packed)) after the closing } of the structs
in question. That should disable padding.
Furthermore I recommend using int32_t instead of long, since long is 8
bytes on 64-bit Linux systems (hence your code wouldn't work on those).
Best regards.
You can also compile with -fpack-struct
(see "man gcc")
But may I suggest that you read your file byte by byte
and feed the structures by reconstructing data with those
bytes (like "x = c1 | (c2 << 8) | (c3 << 16)" or something)?
It is the most portable solution and if your
programs don't spend all of their time in reading these
headers then there is no need to "optimize." (And you
won't waste a lot of time debugging in that direction...)
Regards,
Cédric.