Article View: comp.sys.amiga.tech
Article #12261Re: Determining structure field offsets
From: Sean Reifschneider
Date: Wed, 19 Apr 1989 22:09
Date: Wed, 19 Apr 1989 22:09
19 lines
863 bytes
863 bytes
>'sizeof' operator. Wouldn't it be correct to use something like:
>
> offset_to_second_field = sizeof(structure.first_field)
Only if you wanted the second element of the structure. If there
are an unknown number of elements (0..n) in the structure:
offset_to_N_field = pointer_to_N - pointer_to_structure
or:
struct { int foo, bar; } *baz;
long offset;
offset = ((long) &baz->bar) - ((long) baz);
works.
Sean
Technical Details
Message-ID:
<11640016@hpfcdc.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpfcdc!jafoReferences:
<9270@watcgl.waterloo.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpfcdc!jafo From: jafo@hpfcdc.HP.COM (Sean Reifschneider) Newsgroups: comp.sys.amiga.tech Subject: Re: Determining structure field offsets Message-ID: <11640016@hpfcdc.HP.COM> Date: 19 Apr 89 22:09:45 GMT References: <9270@watcgl.waterloo.edu> Organization: HP Ft. Collins, Co. Lines: 19