From owner-freebsd-questions Sun Mar 14 17:36:52 1999 Delivered-To: freebsd-questions@freebsd.org Received: from saturn.spel.com (ip226-39-143.spel.com [208.226.39.143]) by hub.freebsd.org (Postfix) with ESMTP id C967815D3A for ; Sun, 14 Mar 1999 17:36:09 -0800 (PST) (envelope-from mturpin@saturn.spel.com) Received: from localhost (mturpin@localhost) by saturn.spel.com (8.9.2/8.9.2) with ESMTP id UAA06710; Sun, 14 Mar 1999 20:30:43 -0500 (EST) (envelope-from mturpin@saturn.spel.com) Date: Sun, 14 Mar 1999 20:30:43 -0500 (EST) From: Mark Turpin To: Thomas David Rivers Cc: ian@bulinfo.net, freebsd-questions@FreeBSD.ORG Subject: Re: Programming Question In-Reply-To: <199903150131.UAA10509@lakes.dignus.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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