endian dilemma

Derek Atkins warlord at MIT.EDU
Sat Sep 7 09:40:47 EDT 2002


"Derek D. Martin" <ddm at pizzashack.org> writes:

> Am I counting wrong?
> 
> > struct {
> > 	char a;   /* 1 byte */
> > 	long b;   /* 8 bytes */
> > };
> > The size of the struct on a 32 bit CISC system might be 9 bytes, but on a 
> > 32 bit RISC would be 8 bytes long, because field b must be aligned on a 32 
> > bit boundary.
> 
> How does one fit 9 bytes into 8 bytes?  Wouldn't it have to be 12
> bytes?

I can certainly see how this struct could be either 5, 6, or 8 on a
32-bit system.  I'm not sure where 9 comes from.  On a 64-bit system I
can see it being 9, 10, 12, or 16 bytes...

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available



More information about the Discuss mailing list