What is the default structure packing using cl/gcc/clang?

On msdn for cl compiler option /Zp, it is mentioned that “Packs structures on 8-byte boundaries (default).” Does that mean that if there a data type of size > 8 bytes, by default (no compiler option or pragma pack) it would not be naturally aligned and rather will have 8 byte alignment. If yes, is that case with GCC/clang?

I checked on GCC, using -fpack-struct and __uint128_t, that it does not have any such default. For example sizeof(tStruct) is 32 and 24:

struct tStruct {
uint64_t    a;
__uint128_t b;
};

I am not able to check the same on windows as it does not provide any data type > 8 bytes.


Source: gcc

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.