Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-12

problem with procedural types

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dariusz Mazur

Hi
I upgrade Lazarus and FPT to current snapshot an I have problem

I can compile this procedure

procedure tForm1.MouseCLick(sender:tObject);
begin
end;
procedure tForm1.onnn(var onc : tNotifyEvent);
begin
  onclick:={$IFDEF ;
end;

compiler claim:
Error: incompatible types: got "Pointer" expected "<procedure variable type of procedure(TObject) of object; Register>"

when I try
onclick:={$IFDEF ;

till now everything were OK

Darek

Jonas Maebe
to Dariusz Mazur
Dariusz Mazur wrote 8 lines
procedure tForm1.onnn(var onc : tNotifyEvent); begin onclick:={$IFDEF ; 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 ; (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 ;

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

Dariusz Mazur
to Jonas Maebe

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
and now all must be deleted or I don't know something

Darek

Show quoted text 40 lines
On Dec 18, 2004, at 21:01, Dariusz Mazur wrote: > procedure tForm1.onnn(var onc : tNotifyEvent); > begin > onclick:={$IFDEF ; > 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 ; (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 ; 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 - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jonas Maebe
to Dariusz Mazur
Dariusz Mazur wrote
But when it was changed (if any)

Several procvar bugs have been fixed lately. There have been no deliberate changes, although there may be some due to the fixes.

I port all my source to FPC (it compile in both Delphi and FPC) in many places I use {$IFDEF and now all must be deleted

Definitely not all of them.

or I don't know something

If you compile your sources in Delphi mode (-Sd, or add {$mode delphi} at the top of each source file), you should not have to change much if anything. If you do have to change things, please report them as bugs.

Jonas