是否有一些技巧如何在 Lazarus / delphi 中获取成员函数的指针?我有这个无法编译的代码....
Delphi 中出现错误:
variable required
在 Lazarus 中:
Error: Incompatible types: got "<procedure variable type of function(Byte):LongInt of object;StdCall>" expected "Pointer"
编码:
TClassA = class
public
function ImportantFunc(AParameter: byte): integer; stdcall;
end;
TClassB = class
public
ObjectA: TClassA;
ImportantPtr: pointer;
procedure WorkerFunc;
end;
function TClassA.ImportantFunc(AParameter: byte): integer; stdcall;
begin
// some important stuff
end;
procedure TClassB.WorkerFunc;
begin
ImportantPtr := @ObjectA.ImportantFunc; // <-- ERROR HERE
end;
谢谢!