[fpc-pascal] problem with procedural types

Dariusz Mazur darekm at emadar.com
Sat Dec 18 21:37:07 CET 2004


Jonas Maebe wrote:
But when it was changed (if any)

I port all my source to FPC (it compile in both Delphi and FPC)
in many places I use  {$IFDEF FPC}@{$ENDIF}
and now all must be deleted or I don't know something


Darek

>
> 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
>
>
> _______________________________________________
> 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