[fpc-pascal] How to find address of record member
Bo Berglund
bo.berglund at gmail.com
Sun Jul 8 19:08:00 CEST 2018
On Sun, 08 Jul 2018 18:28:34 +0200, Bo Berglund
<bo.berglund at gmail.com> wrote:
>I tried this:
>var
> offs: word;
>begin
> ...
> offs := @FAppData.Info - @FAppData; //Info is 4th member of record
> address := AppBase + (AppNumber -1) * (SizeOf(TAppData) div 2) +
>offs;
>
>But it was not accepted by the compiler (on the offs := line)...
>Error: Operator not applicable to this operand type
But typecasting the operation fixed the problem:
offs := Cardinal(@FAppData.Info) - Cardinal(@FAppData);
No compiler errors here anymore.
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list