Date: Sun, 14 Mar 1999 20:30:43 -0500 (EST) From: Mark Turpin <mturpin@saturn.spel.com> To: Thomas David Rivers <rivers@dignus.com> Cc: ian@bulinfo.net, freebsd-questions@FreeBSD.ORG Subject: Re: Programming Question Message-ID: <Pine.BSF.4.05.9903142029490.6705-100000@saturn.spel.com> In-Reply-To: <199903150131.UAA10509@lakes.dignus.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks.. That answered my question! Mark On Sun, 14 Mar 1999, Thomas David Rivers wrote: > > Not exactly... the size of the structure depends on the maximum alignment > requirements of all of its members. > > In this case; on most architectures, the alignment of the `shortvariable' > is 2, the alignment of `charvariable' is 1. > > So, the alignment of the entire structure is 2. The size of the > structure is then padded - so that if you had an array of these structures, > each array element would be properly aligned so that the structure > alignment is preserved. Thus, the size of the structure is padded to > reach a two-byte alignment... adding one byte... making the size 4. > > That's why; when dealing with structures - the whole is typically greater > than the sum of the parts... :-) > > - Dave Rivers - > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9903142029490.6705-100000>