Further to what Richard and Greg have said, there are a couple of other things that you can look into. GCC has a
-mms-bitfields
compiler flag that aligns bitfields in the same order as Microsoft VSCC, and
#pragma ms_struct on
to provides the same struct/union layout as MS. The latter generates an unknown pragma warning when compiling in 64 bit mode, but there's also
__attribute__((ms_struct))
, which does the same thing, and does not generate a warning. You'll probably have to do some testing to get the right combination of flags/pragmas/attributes to see if you can get your structs to lay out in the same order on all systems.
Structure-Layout Pragmas (Using the GNU Compiler Collection (GCC))[
^]
x86 Options (Using the GNU Compiler Collection (GCC))[
^]
Also note what
Fixed width integer types (since C99) - cppreference.com[
^] says about
_fastn_t integer types : i.e.
Quote:
fastest [un]signed integer type with width of at least 8, 16, 32 and 64 bits respectively
This indicates that
fast types only guarantee a minimum width, not an exact width, so using them where portability of data is required is not recommended.