In 'C', you must use union to force alignment if you don't want to rely on compiler options or directives:
#include <stdint.h> typedef union _foo { uint64_t align; double d; } foo
This ensures that yours double with 64-bit alignment, it just makes accessing them a little more tedious.
Alternatively, if you donβt mind relying on the compiler, gcc supports the #pragma pack(64) directive, which provides 64-bit alignment for everything.
source share