Why is the “alignment” the same on 32-bit and 64-bit systems?
问题 I was wondering whether the compiler would use different padding on 32-bit and 64-bit systems, so I wrote the code below in a simple VS2019 C++ console project: struct Z { char s; __int64 i; }; int main() { std::cout << sizeof(Z) <<"\n"; } What I expected on each "Platform" setting: x86: 12 X64: 16 Actual result: x86: 16 X64: 16 Since the memory word size on x86 is 4 bytes, this means it has to store the bytes of i in two different words. So I thought the compiler would do padding this way: