On Aug 12, 2012, at 1:57 AM, Vincent Habchi <vi...@macports.org> wrote:

> That’s from the hardware side. Unfortunately, since most people gave up 
> programming in assembly (what a loss! ;)) in favor of C, its derivatives, or 
> other various high level languages, there was a need to nail down the width 
> of various data type. So we ended up with a 'int' 32-bit wide, which was the 
> most reasonable choice at the time the C was normalized because processors 
> had 32-bit data and address registers, and as a side benefit, we could bet 
> that sizeof (int) = sizeof (void *). When these moved to 64-bit, C 'int' 
> should have followed, since both data and address registers were doubled, but 
> it was not done (why? Because we would have lacked a 32-bit qualifier? Some 
> other side effect?). So we ended up with sizeof (int) != sizeof (void *). And 
> mainly I guess that’s what is meant by '64-bit' from the developer point of 
> view, besides – of course – utilizing libraries compiled with the 64-bit 
> instruction set.

The reason that sizeof(int) != sizeof(void *) goes back to programmer laziness 
(really!).

For years, files were written that assumed that sizeof(int) was 4 bytes, even 
though the long data type was explicitly designed for that value, AND types 
were introduced to the language that explicitly defined bit lengths (int8_t, 
int16_t, int32_t, int64_t).  However, because programmers generally are lazy 
and didn't want to go back an re-code all of their legacy code to use the new 
bit-length-defined types, and because the C language "allowed" it (sizeof(char) 
<= sizeof(short) <= sizeof(int) <= sizeof(long)), the standards body "froze" 
int as a 32-bit value.

-- 
Glenn L. Austin, Computer Wizard and Race Car Driver         <><
"Where there's breath, there's hope!"
<http://www.austin-soft.com>


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to