I have to do some record sub-data size calculation so created something like
function GetSubDataSize(const Rec: TRecord): integer;
begin
Result:=integer(@Rec.Field2) - integer(@Rec.Field1);
end;
Everything is ok except for one case, if one of Field is a procedure or function pointer, so in case of
TRecord = record
Field2: procedure(Sender: TObject) of object;
end;
The function gets the address of the procedure itself. Is there a way to typecast the field to get the address of the field not the address of the function? I know that I can solve it with variant part records, but just prefer not to use it.
Thanks,
Max