C Integers

Jose-Marcio Martins Jose-Marcio.Martins@mines-paristech.fr
Mon May 6 12:01:00 GMT 2013


JimJoyce wrote:
> When Dennis Ritchie invented the C Programming language, he suggested that a
> short int would normally occupy 2 bytes, and a long int would take 4 bytes,
> and no matter what the hardware, a long should always be longer than a
> short. That makes sense.
> However, he was less precise about the simple int. He simply stated that it
> should reflect the 'natural' size of the hardware. So it might be like a
> short on one machine, while like a long on another.
>
> Am I 'out of date' and 'out of touch'?
> Machines and compilers have grown in size since Ritchie's day
> When I check sizeof(short), sizeof(int) and sizeof(long) on my machine I get
> 2, 2, 4.
> Yet my machine is a 64bit one. Is that its 'natural' size. Should not my int
> be 8 bytes ??
> Should C and C++ compilers be re-defining shorts, ints and longs?

IMHO, this is an interesting question

Your machine is a "64bit" one ! But you're telling about the processor or the operating system ?

Most of the time, when someone say something about choosing between a 64 or 32 bits OS, what he has 
in his mind isn't the wide of the data, but the size of the memory address space the OS is able to 
handle.



-- 



More information about the Gcc-help mailing list