不兼容的类型:Delphi XE4中的'PPointerList'和'TPointerList'

时间:2013-10-09 08:38:58

标签: delphi delphi-7 delphi-xe4

我在以下函数中收到错误Incompatible types: 'PPointerList' and 'TPointerList'

function MyFunction: PPointerList;
begin
  result := FList.List;
end;

FList.List返回TPointerList类型。这段代码在Delphi 7代码中运行良好,但在Delphi XE4中抛出错误。

PPointerList和TPointerList在System.Classes

中声明

在System.Classes

PPointerList = ^TPointerList;
TPointerList = array of Pointer;

当我将TPointerList类型化为PPointerList时,它就像

一样
function MyFunction: PPointerList;
begin
  result := PPointerList(FList.List);
end;

这是正确的解决方案,或者我该怎么做才能摆脱这个错误。

1 个答案:

答案 0 :(得分:7)

TList已发生变化。内部字段FList曾是PPointerList,但现在是TPointerList。要返回指向它的指针,可以使用:

function MyFunction: PPointerList;
begin
  Result := @FList.List;
end;