sizeof(int)

Issac issac at myfirstlink.net
Sun Dec 30 18:13:36 EST 2001


I agree.  C isn't a bad language, it's just hardware-centric.

Issac

> > He's probably trying to drive home the point that sizeof(int) isn't 
> > well-defined in the C language.  On C implementations with 16-bit
> integers, the 
> > function call results in an overflow.  In this case, the answer is 23575.
> 
> Your phrasing ("sizeof(int) isn't well-defined") helped me see the
> fundamental issue:  in my mind, sizeof(int) _is_ well-defined, that is to
> say, it is defined as the machine-word-size on whatever platform is being
> used.  Of course, this varies from machine to machine, but maybe this
> should be seen as hardware word-sizes being poorly-defined ;-)  One of the
> big goals of C was efficiency, so defining ints this way made sense
> (sizeof(int) equals size of CPU register).  This is also why C is good for
> writing to bare-metal: it is defined in terms of the machine.  Other
> languages that attempt to hide the underlying hardware architecture are
> best for typical applications that don't care about the hardware, but can
> get in the way or make it burdensome to write code that deals directly with
> hardware.  On the downside, it does affect portability, but any code that
> deals with hardware is going to have issues like this.
> 
> 
> Cliff
> 
> 
> -- 
> Cliff Wells
> Software Engineer
> Logiplex Corporation (www.logiplex.net)
> (503) 978-6726 x308
> (800) 735-0555 x308


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.310 / Virus Database: 171 - Release Date: 12/19/2001





More information about the Python-list mailing list