[fpc-pascal] How to get the offset of a record

Aleksa Todorovic alexione at gmail.com
Sat Apr 30 14:54:22 CEST 2011


On Sat, Apr 30, 2011 at 14:30, Rainer Stratmann
<RainerStratmann at t-online.de> wrote:
> In Turbopascal it was possible with offs()
>
> type
>  rectype = record
>  var1 : longint;
>  var2 : longint;
>  var3 : boolean;
>  end;
>
> var
>  o : longint;
>  recvar : rectype;
>
>  o := offs( recvar.var1 );  // --> 0
>  o := offs( recvar.var2 );  // --> 4
>  o := offs( recvar.var3 );  // --> 8

o := PtrUInt( @recvar.var1 ) - PtrUInt( @recvar );
o := PtrIUnt( @recvar.var2 ) - PtrUInt( @recvar );
o := PtrInUt( @recvar.var3 ) - PtrUInt( @recvar );

> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



More information about the fpc-pascal mailing list