Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!tektronix!tekcrl!tekfdi!bobb From: bobb@tekfdi.FDI.TEK.COM (Robert Bales) Newsgroups: comp.sys.amiga.tech Subject: Re: Determining structure field offsets Message-ID: <2964@tekfdi.FDI.TEK.COM> Date: 20 Apr 89 17:14:46 GMT References: <9270@watcgl.waterloo.edu> <17372@cup.portal.com> Reply-To: bobb@tekfdi.FDI.TEK.COM (Robert Bales) Distribution: usa Organization: Tektronix, Inc., Beaverton, OR. Lines: 20 In article <17372@cup.portal.com> FelineGrace@cup.portal.com (Dana B Bourgeois) writes: >Jeff Kelley wants to calculate the offset in a structure. >Wouldn't it be correct to use something like: > offset_to_second_field = sizeof(structure.first_field) There is often more than meets the eye to the size of structures. The start of the structure will (almost certainly) be longword aligned, that is have an address evenly divisible by 4. If "first_field" is a char, it will have sizeof = 1. But if "second_field" is a long, it must be longword aligned (on the 68000), and 3 padding bytes will be placed between the first two fields, with the offset of the second being 4. Bob Bales Tektronix, Inc. I help Tektronix make their instruments. They don't help me make my opinions.