I have a procedure....
function AS3935init(device:string; target:cint; irq:integer; irqproc:tirqready; var fhandle):boolean;
It lives in a unit and is very happy there. From a button I call :
if as3935init ('/dev/i2c-1', $03, 17,@as3935tripped, as3935_handle) then memo1.lines.add('AS3935 Ready');
All is well, it compiles and runs. The routing as3935tripped contains:
procedure tform1.as3935tripped (irqnr:integer;edge:boolean);
begin
if edge then memo1.lines.add (timetostr(time)+': AS3935 Leading IRQ! '+gpios[irqnr].name)
else memo1.lines.add (timetostr(time)+': AS3935 Falling IRQ! '+gpios[irqnr].name)
end;
So far so good.
as3935tripped needs to go in the unit though, the end user has no need to monkey with it. So moved the procedure over. Its called with *exactly* the same parameters and now fails to compile with:
unit1.pas(316,50) Error: Incompatible type for arg no. 4: Got "<address of procedure(LongInt,Boolean);StdCall>", expected "<procedure variable type of procedure(LongInt,Boolean) of object;StdCall>"
I'm guessing the 'object' is the key here but I'm stumped. Is it because its not longer part of the applications form?