🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Determining structure field offsets

#12262
From: Randell Jesup
Date: Thu, 20 Apr 1989 22:32
16 lines
1191 bytes
In article <38874@bbn.COM> cosell@BBN.COM (Bernie Cosell) writes:
>In article <11940@grebyn.COM> ckp@grebyn.COM (Checkpoint Technologies) writes:
>}
>}Someone asked about calculating structure member offsets in a portable
>}way.  You were close, but try this:
...
>You don't need the dummy variable: it is legal in C (although I don't know
>for ANSI C) to coerce the address '0' to be a pointer to anything.  And so
>        #define offset(s,f)       &(((s *)0)->f)
>works just fine.

	Lattice 5.02 has an offsetof() macro in stddef.h (where ANSI says
it should be).

-- 
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup
Technical Details
Message-ID: <6654@cbmvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!apple!oliveb!amiga!cbmvax!jesup
References: <9270@watcgl.waterloo.edu> <17372@cup.portal.com> <11940@grebyn.COM> <38874@bbn.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!apple!oliveb!amiga!cbmvax!jesup
From: jesup@cbmvax.UUCP (Randell Jesup)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Determining structure field offsets
Message-ID: <6654@cbmvax.UUCP>
Date: 20 Apr 89 22:32:32 GMT
References: <9270@watcgl.waterloo.edu> <17372@cup.portal.com> <11940@grebyn.COM> <38874@bbn.COM>
Reply-To: jesup@cbmvax.UUCP (Randell Jesup)
Distribution: usa
Organization: Commodore Technology, West Chester, PA
Lines: 16