Type sizes

Brad Ahlf bla at hpcupt1.HP.COM
Tue Aug 30 09:48:36 AEST 1988


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



More information about the Comp.lang.c mailing list