I\'m looking for detailed information regarding the size of basic C++ types. I know that it depends on the architecture (16 bits, 32 bits, 64 bits) and the compiler.
There is standard.
C90 standard requires that
sizeof(short) <= sizeof(int) <= sizeof(long)
C99 standard requires that
sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)
Here is the C99 specifications. Page 22 details sizes of different integral types.
Here is the int type sizes (bits) for Windows platforms:
Type C99 Minimum Windows 32bit
char 8 8
short 16 16
int 16 32
long 32 32
long long 64 64
If you are concerned with portability, or you want the name of the type reflects the size, you can look at the header
, where the following macros are available:
int8_t
int16_t
int32_t
int64_t
int8_t
is guaranteed to be 8 bits, and int16_t
is guaranteed to be 16 bits, etc.