This is about memory alignment. In code below, I expected that the offset of b inside the structure to be 8 (32-bit machine). See here. There by, making b
alway
According to the System V ABI for i386, page 28, double
only gets 4 bytes alignment, but compilers are recommended to provide an option for 8 bytes as well. It appears this is what is implemented by GCC on Linux, the option being called -malign-double
.
Another alternative is to use -m64
to get x86-64 object code, which is already the default on some systems including Mac OS X.