🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #12267

Re: Determining structure field offsets

#12267
From: Robert Bales
Date: Thu, 20 Apr 1989 17:14
20 lines
1314 bytes
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.
Technical Details
Message-ID: <2964@tekfdi.FDI.TEK.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!tektronix!tekcrl!tekfdi!bobb
References: <9270@watcgl.waterloo.edu> <17372@cup.portal.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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