../
Looking for a senior C++ dev? I'm looking for work. Hire me!

Summary

I've been working on some 32-bit and 64-bit Windows code recently. And I was confused about the size of some types, such as int, long, and long long. So of course I had to compile some test code to compare on different systems.

32-bit and 64-bit types

See the table for a trivial C++ application built on some 32-bit and 64-bit systems:

Type ARM7 32-bit Linux
g++ 4.9
x86 32-bit Linux
g++ 4.8
x64 64-bit Linux
g++ 5.4
x86 32-bit Windows 7
VisualStudio 2013
x64 64-bit Windows 7
VisualStudio 2013
bool 1 1 1 1 1
char 1 1 1 1 1
short 2 2 2 2 2
int 4 4 4 4 4
long 4 4 8 4 4
long long 8 8 8 8 8
float 4 4 4 4 4
double 8 8 8 8 8
long double 8 12 16 8 8
size_t 4 4 8 4 8
void * 4 4 8 4 8
DWORD n/a n/a n/a 4 4
Where the values are the number of bytes each type requires.
Last modified: 2017-10-16
Stéphane Charette, stephanecharette@gmail.com
../