[fpc-devel] Assign static class procedure to procedure variable

Ondrej Pokorny lazarus at kluug.net
Sat Oct 17 09:01:25 CEST 2015


Hello!

In Delphi it is valid to assign a static class procedure to a procedure 
variable:

program project1;

type
   TMyObject = class
   public
     class procedure Proc; static;
   end;

   TProc = procedure();

class procedure TMyObject.Proc;
begin

end;

var
   xProc: TProc;
begin
*  xProc := @TMyObject.Proc;**
*end.

(In Delphi just without the @ operator, obviously.)

In FPC 3.1.1 (trunk) I get the following error:

project1.lpr(22,12) Error: Incompatible types: got "<class method type 
of procedure of object;Register>" expected "<procedure variable type of 
procedure;Register>"

Why? Can it be achieved somehow (compiler settings)?

Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20151017/6e6af5c3/attachment.html>


More information about the fpc-devel mailing list