Using Delphi 7 here. When I take the address of a procedure (with the purpose of sending this method address to an external C++ DLL as a callback) the Delphi 7 compiler reports Variable required
. Why? How do you take the address of a method with or without a parameter list?
Here's my simplified code which shows the compiler error.
// ...
type
PTProcedureCallback = ^TProcedureCallback;
TProcedureCallback = procedure() of object;
// ...
TTestCallback = class
constructor Create();
procedure MyCallback();
end;
//...
implementation
constructor TTestCallback.Create();
var
pCallback: PTProcedureCallback;
begin
// Constructor
inherited;
// Test callback
pCallback := @MyCallback; // <- [Error] Variable required
end;
procedure TTestCallback.MyCallback();
begin
// Do something
end;
end;