Re: [fpc-pascal] How to find address of record member

2018-07-08 Thread Martin
On 08/07/2018 19:08, Bo Berglund wrote: But typecasting the operation fixed the problem: offs := Cardinal(@FAppData.Info) - Cardinal(@FAppData); No compiler errors here anymore. May be a result of {$TYPEDADDRESS On} which may be default in some mode switches. Untyped pointers seem to be s

Re: [fpc-pascal] How to find address of record member

2018-07-08 Thread Bo Berglund
On Sun, 08 Jul 2018 18:28:34 +0200, Bo Berglund 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 t

Re: [fpc-pascal] How to find address of record member

2018-07-08 Thread Bo Berglund
On Sun, 8 Jul 2018 17:16:01 +0200, Martin wrote: >On 08/07/2018 17:07, Bo Berglund wrote: >> Say I have a record type defined like this: >> >>TAppData = packed record //Total 8 bytes per app >> ActiveToken: word; //Matches constant for app if active >> Option: word; //16 optio

Re: [fpc-pascal] How to find address of record member

2018-07-08 Thread Martin
On 08/07/2018 17:07, Bo Berglund wrote: Say I have a record type defined like this: TAppData = packed record //Total 8 bytes per app ActiveToken: word; //Matches constant for app if active Option: word; //16 option bits ExpDate: word; //Integer TDateTime values I

[fpc-pascal] How to find address of record member

2018-07-08 Thread Bo Berglund
Say I have a record type defined like this: TAppData = packed record //Total 8 bytes per app ActiveToken: word; //Matches constant for app if active Option: word; //16 option bits ExpDate: word; //Integer TDateTime values Info: word;//16 info bits end; The da