Size of C/C++ data type from GNU GCC/g++ compiled ELF 64-bit LSB executable, AMD x86-64 vs. ELF 32-bit LSB executable, Intel 80386

Brian Dessent brian@dessent.net
Tue Jun 19 07:54:00 GMT 2007


tom peng wrote:

> Are those 32-bit / 64-bit difference stipulated in C/C++ standard or ruled
> by the GNU/GCC compiler?

All the standard says is that sizeof(short) <= sizeof(int) <=
sizeof(long), it doesn't give any actual numbers, other than
sizeof(char) = 1.  The choice of what the particular values are is
defined by the platform's ABI specification, not gcc.  gcc just follows
the spec for each platform.

It's very broken to assume that sizeof(long) is 4, because that is not
true on almost any 64 bit platform, the major exception begin Windows
x64.  It's especially broken considering that the C99 standard gives you
the header <stdint.h>, which provides int32_t, uint32_t, int64_t,
uint64_t, and so on.

Brian



More information about the Gcc-help mailing list