[comp.lang.c] Type sizes

pardo@june.cs.washington.edu (David Keppel) (08/28/88)

I'd like to know if the numbers and the rationalle are correct.
If you have other personal favorites, be sure to send them to me :-).


type		pdp11	VAX	68000	Cray-2	Unisys 1100	80386

char		8	8	8	8	9		8
short		16	16	8/16	32/64	18		8/16
int		16	32	16/32	32/64	36		16/32
long		32	32	32	64/64	36		32
char*		16	32	32	64/64	72		16/32/48
int*		16	32	32	24/64	72		16/32/48
int(*)()	16	16	16/64	64	576		16/32/48

Some machines have more than one possible size for a given type.
This can depend both on the compiler and on various compile-time
flags.

The *size* of an object does not guarantee the *precision* of that
object.  In particular, the Cray-2 may use 64 bits to store an |int|,
but a |long| cast into an |int| and back to a |long| may be truncated
to 32 bits.

	;-D on  ( Clint "programmer" Eastwood:  "Port *this*! )  Pardo
-- 
		    pardo@cs.washington.edu
    {rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!pardo

bla@hpcupt1.HP.COM (Brad Ahlf) (08/30/88)

>type		pdp11	VAX	68000	Cray-2	Unisys 1100	80386
>
>char		8	8	8	8	9		8
>short		16	16	8/16	32/64	18		8/16
>int		16	32	16/32	32/64	36		16/32
>long		32	32	32	64/64	36		32
>char*		16	32	32	64/64	72		16/32/48
>int*		16	32	32	24/64	72		16/32/48
>int(*)()	16	16	16/64	64	576		16/32/48
>
>Some machines have more than one possible size for a given type.
>This can depend both on the compiler and on various compile-time
>flags.

You should also consider the required *alignment* of the different types
on different machines.
The same type with same size on different machines may differ in alignment.
 
>The *size* of an object does not guarantee the *precision* of that
>object.  In particular, the Cray-2 may use 64 bits to store an |int|,
>but a |long| cast into an |int| and back to a |long| may be truncated
>to 32 bits.

The *size* of an object does not guarantee the alignment of that object
either.  
The *size* of an object also does not guarantee the space needed within
a structure, the *size* and *alignment* do.