Path: utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!ucsd!ucsdhub!hp-sdd!hplabs!hpda!hpcupt1!kluft From: kluft@hpcupt1.HP.COM (Ian Kluft) Newsgroups: comp.lang.c Subject: Re: sizeof( _variable_ ) Message-ID: <5940002@hpcupt1.HP.COM> Date: 22 Jul 88 21:11:12 GMT References: <1264@bc-cis.UUCP> Organization: HP Systems Technology Div, Cupertino CA Lines: 25 john@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@hpda.hp.com Cupertino, CA ------------------------------------------------------------------