I've been working on legacy code maintenance issues and dealing with some code that works around differences between 32-bit and 64-bit builds. And I was confused about the size of some types, such as int, long, and long long. So I compiled some test code to compare on different systems.
Turns out, the operating system is what makes the biggest difference in terms of compatibility across systems, not the hardware. On Windows, going between 32-bit and 64-bit makes little difference. Types such as long are the same. While on Linux and Mac, going from 32-bit to 64-bit means that long increases from 4 bytes to 8 bytes.
But definitely the biggest surprise was long double, which goes from 8 bytes, to 12 bytes, and finally 16 bytes.
(Don't get me started on the fact that int and long are identical on 32-bit systems! And 64-bit Windows... <sigh>)
See the table for the results from a trivial C++ application built on some common 32-bit and 64-bit systems:
|ARM 32-bit Linux
|ARM 64-bit Linux
|x86 32-bit Linux
|x64 64-bit Linux
|x86 32-bit Windows 7
|x64 64-bit Windows 7
|x64 64-bit MacOS 10.15