This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C Integers


On Mon, May 6, 2013 at 7:01 AM, Jose-Marcio Martins
<Jose-Marcio.Martins@mines-paristech.fr> wrote:
> 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.

Also bear in mind your compiler tool chain is likely not building to
the machine, or even the OS, but to an x86 architecture.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]