[fpc-pascal] problem with procedural types
Jonas Maebe
jonas at zeus.ugent.be
Sat Dec 18 21:10:59 CET 2004
On Dec 18, 2004, at 21:01, Dariusz Mazur wrote:
> procedure tForm1.onnn(var onc : tNotifyEvent);
> begin
> onclick:={$IFDEF FPC}@{$ENDIF}onc;
> end;
>
> compiler claim:
> Error: incompatible types: got "Pointer" expected "<procedure variable
> type of procedure(TObject) of object; Register>"
This error message looks correct (at least if you are compiling in fpc
or objfpc mode). onc is a procedure variiable, so @onc is the address
of the procedure variable. You should simply do "onclick := onc", or
possibly even
onclick := {$ifndef fpc}@{endif}onc; (since Delphi requires an @ to get
the contents of a procvar)
(at least if both onclick and onc are of type tnotifyevent and if
tnotifyevent is a procvar type).
> when I try
> onclick:={$IFDEF FPC}@{$ENDIF}MouseClick;
In this case, the right hand side of the expression is a method, so you
indeed need @ in FPC mode to get its address.
Jonas
More information about the fpc-pascal
mailing list