[fpc-pascal] Function Pointers

Brent Smith brentdsmith at yahoo.com
Thu Sep 7 15:02:07 CEST 2006


I am trying to use function/procedure pointers with
the FPC version 2.0.2 on Windows 2000.  The complete
test program is given below.  The error is "Wrong
number of parameters specified".  When I put this into
Delphi 5 then it works no problem and prints 25 as
expected.  Any suggestions or is this a current
limitation of the compiler?

Thanks,

Brent Smith

***** Program: *****

program TestPtrs;

uses
  SysUtils

type
  IntFunc = function (Num: Integer) : Integer;

var
  PtrToFunc : IntFunc;
  x : Integer;

{ Multiply by five. }
function TestPtr2(Num: Integer): Integer;
begin
   TestPtr2 := 5 * Num ;
end;

begin
  x := 5;
  {
     Error: Wrong number of parameters specified
    Hint: Found declaration:TestPtr2(LongInt):LongInt
    TestPtrs.pas(34, stopping
  }
  PtrToFunc := TestPtr2;
  writeln(PtrToFunc(x));
  readln;

end.
    

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the fpc-pascal mailing list