[fpc-pascal] method pointers

Wolfram Kläger wolfram.klaeger at web.de
Tue Jan 17 01:45:01 CET 2006


FPC can´t assign value to address, where Delphi can. For example:

TDomNode = class(TDomCustomNode);
  private
      ...
      FUserData : TUtilsWideStringList;
      FUserDataHandlers : TList;
      ...
 
destructor TDomNode.Destroy;
var
  I: Integer;
  UserDataEvent: TDomUserDataEvent;
begin
  // Call user data event handlers:
  if Assigned(FUserData) then
    with FUserData do
      for I := 0 to Pred(Count) do begin
        @UserDataEvent := pointer(FUserDataHandlers[I]);
        if Assigned(UserDataEvent) then
          UserDataEvent(OT_NODE_DESTROYED, WideStrings[I], Objects[I], nil, nil);
      end;
...

In Delphi, the line

        @UserDataEvent := pointer(FUserDataHandlers[I]);

is common practice. What is the difference to FPC and the appropriate workaround?

Thanks in advance
Wolfram



More information about the fpc-pascal mailing list