Types sizes

Summary

 Legend:

  Standard behavior
  Standard and a grateful surprise: other compilers/platforms fail
  Standard but be careful: different from everywhere else
  Unexpected: probably a compiler bug or missing feature

 

Numerical type sizes in C (bits)
Platforms  \   Types char short int size_t ssize_t long long long void* off_t float double
Win32, gcc nuwen 7.2 8 16 32 32 32 32 64 32 32 32 64
Win32, gcc nuwen 7.2 LFF 8 16 32 32 32 32 64 32 32 32 64
Win32, MSVC 8 16 32 32 - 32 64 32 32 32 64
Linux32, gcc 8 16 32 32 32 32 64 32 32 32 64
Linux32, gcc LFF 8 16 32 32 32 32 64 32 64 32 64
Win64, gcc mingw64 8 16 32 64 64 32 64 64 32 32 64
Win64, gcc mingw64 LFF 8 16 32 64 64 32 64 64 64 32 64
Win64, MSVC 8 16 32 64 - 32 64 64 32 32 64
Linux64, gcc 8 16 32 64 64 64 64 64 64 32 64
Linux64, gcc LFF 8 16 32 64 64 64 64 64 64 32 64

 

Windows 32-bit, gcc 4.6.1-nuwen7.2

C:\arisnova\zsync\blah\typesize\mingw-build>sizes.exe
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 32 bits  (MAX VALUE: size_t  = 536870911
ssize_t size: 32 bits  (MAX VALUE: ssize_t  = 1073741823
long size: 32 bits  (MAX VALUE: signed long  = 536870911, unsigned long = 1073741823)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 1073741823)
void* size: 32 bits
off_t size: 32 bits
float size: 32 bits
double size: 64 bits

 

Windows 32-bit, gcc 4.6.1-nuwen7.2 -D_FILE_OFFSET_BITS=64

C:\arisnova\zsync\blah\typesize\mingw-build>sizes
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 32 bits  (MAX VALUE: size_t  = 536870911
ssize_t size: 32 bits  (MAX VALUE: ssize_t  = 1073741823
long size: 32 bits  (MAX VALUE: signed long  = 536870911, unsigned long = 1073741823)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 1073741823)
void* size: 32 bits
off_t size: 32 bits
float size: 32 bits
double size: 64 bits

, therefore an alternative mechanism for large file support is required

 

Windows 64-bit, gcc 4.7.0-mingw-w64 20080827 experimental

C:\arisnova\zsync\blah\typesize\mingw64-build>sizes.exe
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 64 bits  (MAX VALUE: size_t  = 144115188075855871
ssize_t size: 64 bits  (MAX VALUE: ssize_t  = 288230376151711743
long size: 32 bits  (MAX VALUE: signed long  = 536870911, unsigned long = 1073741823)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 1073741823)
void* size: 64 bits
off_t size: 32 bits
float size: 32 bits
double size: 64 bits

 

Windows 64-bit, gcc 4.7.0-mingw-w64 20080827 experimental -D_FILE_OFFSET_BITS=64

C:\arisnova\zsync\blah\typesize\mingw64-build>sizes.exe
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 64 bits  (MAX VALUE: size_t  = 144115188075855871
ssize_t size: 64 bits  (MAX VALUE: ssize_t  = 288230376151711743
long size: 32 bits  (MAX VALUE: signed long  = 536870911, unsigned long = 1073741823)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 1073741823)
void* size: 64 bits
off_t size: 64 bits
float size: 32 bits
double size: 64 bits

 

 

Windows 32-bit, MSVC2010 SP1 32-bit

C:\arisnova\zsync\blah\typesize\msvc-build\Debug>sizes.exe
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 32 bits  (MAX VALUE: size_t  = 536870911
long size: 32 bits  (MAX VALUE: signed long  = 536870911, unsigned long = 1073741823)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 1073741823)
void* size: 32 bits
off_t size: 32 bits
float size: 32 bits
double size: 64 bits

 

Windows 64-bit, MSVC2010 SP1 64-bit

C:\arisnova\zsync\blah\typesize\msvc64-build\Debug>sizes.exe
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 64 bits  (MAX VALUE: size_t  = 144115188075855871
long size: 32 bits  (MAX VALUE: signed long  = 536870911, unsigned long = 1073741823)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 1073741823)
void* size: 64 bits
off_t size: 32 bits
float size: 32 bits
double size: 64 bits

 

Linux 32-bit, gcc 4.5.2-8buntu4

pgquiles@mcpau:~/tmp$ ./sizes
char size: 8 bits (MAX VALUE: signed char = 255, unsigned char = 511)
short size: 16 bits (MAX VALUE: signed short = 32767, unsigned short = 65535)
int size: 32 bits (MAX VALUE: signed int = 536870911, unsigned int = 1073741823)
size_t size: 32 bits (MAX VALUE: size_t = 536870911
ssize_t size: 32 bits (MAX VALUE: ssize_t = 1073741823
long size: 32 bits (MAX VALUE: signed long = 536870911, unsigned long = 1073741823)
long long size: 64 bits (MAX VALUE: signed long long = 144115188075855871, unsigned long long = 1073741823)
void* size: 32 bits
off_t size: 32 bits
float size: 32 bits
double size: 64 bits   

 

Linux 32-bit, 

pgquiles@sid32:~/typesize/build-linux64$ ./sizes
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 32 bits  (MAX VALUE: size_t  = 536870911
ssize_t size: 32 bits  (MAX VALUE: ssize_t  = 1073741823
long size: 32 bits  (MAX VALUE: signed long  = 536870911, unsigned long = 1073741823)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 1073741823)
void* size: 32 bits
off_t size: 64 bits
float size: 32 bits
double size: 64 bits

 

Linux 64-bit, gcc 4.5.2-8ubuntu4

pgquiles@nattyserver:~/a$ ./sizes
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 64 bits  (MAX VALUE: size_t  = 144115188075855871
ssize_t size: 64 bits  (MAX VALUE: ssize_t  = 288230376151711743
long size: 64 bits  (MAX VALUE: signed long  = 144115188075855871, unsigned long = 288230376151711743)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 288230376151711743)
void* size: 64 bits
off_t size: 64 bits
float size: 32 bits
double size: 64 bits

 

Linux 64-bit, gcc 4.5.2-8ubuntu4

pgquiles@nattyserver:~/typesize/build-linux$ ./sizes
char size:  8 bits  (MAX VALUE: signed char  = 255, unsigned char = 511)
short size: 16 bits  (MAX VALUE: signed short  = 32767, unsigned short = 65535)
int size: 32 bits  (MAX VALUE: signed int  = 536870911, unsigned int = 1073741823)
size_t size: 64 bits  (MAX VALUE: size_t  = 144115188075855871
ssize_t size: 64 bits  (MAX VALUE: ssize_t  = 288230376151711743
long size: 64 bits  (MAX VALUE: signed long  = 144115188075855871, unsigned long = 288230376151711743)
long long size: 64 bits  (MAX VALUE: signed long long  = 144115188075855871, unsigned long long = 288230376151711743)
void* size: 64 bits
off_t size: 64 bits
float size: 32 bits
double size: 64 bits