C Integers

NeonJohn jgd@neon-john.com
Mon May 6 12:30:00 GMT 2013



On 05/06/2013 07:11 AM, JimJoyce wrote:

> 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?

I'm not a compiler guy but I do a lot of low level programming where the
object size is important.

In general, the int, float, etc notation has been displaced by the _t
notation.  That is if you want an 8 bit signed object you declare it

int8_t foo.

A 16 bit unsigned object would be

uint16_t foo

It is the responsibility of the compiler writer to convert these into
the target machine's object sizes.  For example, the ARM GNU C
cross-compiler I'm currently working with, the int8_t is typedef'ed as a
char.

Look in <sys/types.h> for all the typedefs.  This is also discussed in
the GNU C standard library manual.

John


-- 
John DeArmond
Tellico Plains, Occupied TN
http://www.fluxeon.com      <-- THE source for induction heaters
http://www.neon-john.com    <-- email from here
http://www.johndearmond.com <-- Best damned Blog on the net
PGP key: wwwkeys.pgp.net: BCB68D77



More information about the Gcc-help mailing list