我正在将一个项目从Delphi 2006升级到Delphi XE2,并且遇到编译错误没有可以用这些参数调用的'SendMsg'重载版本。
这是问题所在的代码。

procedure TMessageComms.UpgradeError(Msg: String);
begin
  FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID);
end;


SendMsg方法看起来像这样。

procedure SendMsg(ACommand, AParamStr : String; AMsgID : Integer); overload;

procedure TMsgConnection.SendMsg(ACommand, AParamStr: String; AMsgID: Integer);
begin
  // construct message
  // send message
end;


cUpgradeError是这样声明的常量。

 cUpgradeError = 'UpgradeError';


这是返回一个整数的GetNextMsgID函数。

function TMsgConnection.GetNextMsgID: Integer;
begin
  Inc(FLastMsgID);
  Result := FLastMsgID;
end;


这些参数对我来说似乎都是有效的。
我设法将其缩小到与GetNextMsgID函数有关的程度,但是不确定。如果我将函数返回的值转换为Integer,那么它可以很好地编译,但是我看不到为什么必须这样做。

最佳答案

我的猜测是FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID);试图将FConnection.GetNextMsgID解释为函数指针而不是函数结果。

将其更改为FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID());,这样很明显您正在寻找函数结果。

关于delphi - 没有可以使用这些参数调用的“SendMsg”的重载版本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14410651/

10-08 22:41