sizeof( _variable_ )

Ian Kluft kluft at hpcupt1.HP.COM
Sat Jul 23 07:11:12 AEST 1988


john at bc-cis.UUCP (John L. Wynstra) writes:
> 	I recently ran up against this one, and, would like to toss it out to
> NetLand.  I had coded (on a 3b2 running System V.3) the following,
> 
> typedef struct {
> 	char	x[10];
> 	char	y;
> 	char	xx[10];
> 	char	yy;
> } Stuff;
> 
> Stuff z;
> 
> Later on in the same code I had a reference to sizeof(z) expecting to get 22
> (which is btw what I just now got on the bsd 4.2 vax), but what I got was 24!

The 3B2 runs AT&T's WE32000 series processors.  They're 32 bit machines and
align structures on 4-byte (1-machine word) boundaries.  That way, in an array
of these structures, items after the first are still properly aligned.

------------------------------------------------------------------
    Ian Kluft			RAS Lab
    UUCP: hplabs!hprasor!kluft	HP Systems Technology Division
    ARPA: kluft at hpda.hp.com	Cupertino, CA
------------------------------------------------------------------



More information about the Comp.lang.c mailing list