首页 > 解决方案 > E2251 对“StrLen”SysUtils.pas(7863) 的模糊重载调用:

问题描述

我的代码如下。使用 Windows 10,Delphi 2010。SysUtils.pas文件中的错误:

[DCC Error] OTFEFreeOTFE_U.pas(3199): E2251 Ambiguous overloaded call to 'StrLen'
  SysUtils.pas(7863): Related method: function StrLen(const PAnsiChar): Cardinal;
  SysUtils.pas(7892): Related method: function StrLen(const PWideChar): Cardinal;

代码片段如下:

function StrLen(const Str: PAnsiChar): Cardinal;
asm
  {Check the first byte}
  cmp byte ptr [eax], 0
  je @ZeroLength
  {Get the negative of the string start in edx}
  mov edx, eax
  neg edx
  {Word align}
  add eax, 1
  and eax, -2
@ScanLoop:
  mov cx, [eax]
  add eax, 2
  test cl, ch
  jnz @ScanLoop
  test cl, cl
  jz @ReturnLess2
  test ch, ch
  jnz @ScanLoop
  lea eax, [eax + edx - 1]
  ret
@ReturnLess2:
  lea eax, [eax + edx - 2]
  ret
@ZeroLength:
  xor eax, eax
end;

标签: delphi-2010

解决方案


推荐阅读