delphi - 对 UInt64 感到困惑

标签 delphi delphi-xe2 uint64

下面的代码片段演示了我最近从最近的 ISO 镜像文件重新安装的 Delphi XE2 中的文本 IO 和 UInt64 类型变量遇到的问题 - 编译失败,并出现与缺少 Text.ReadUInt64 函数相关的错误消息或程序。如果我用

替换失败的行
  ReadLn(F,A);

然后程序编译,正确写入

-1
18446744073709551615

到文本文件,然后(如预期)在第二次读取时失败,并出现 EInOutError:“无效的数字输入”。我的安装是否损坏或者有人未能编写 ReadUInt64 函数?我在帮助中找到的对 ReadUInt64 的唯一引用是以下定义:

function ReadUInt64: UInt64; virtual;

在 System.Classes.TBinaryReader.ReadUInt64 中。我不确定这是否是“相同”功能,或者如果是,为什么它是虚拟的......

我对帮助中对 UInt64 的引用也有点困惑。它将其定义为:

type UInt64 = Int64;

如果这是正确的,编译器如何知道以不同方式对待 UInt64 和 Int64 变量?

procedure TForm1.Button1Click(Sender: TObject);
var
  F : TextFile;
  A : Int64;
  B : Uint64;
begin
{
Compiler warns on following line with message:
[DCC Warning] Unit1.pas(32): W1012 Constant expression violates subrange bounds
}
  A := $FFFFFFFFFFFFFFFF;
  B := $FFFFFFFFFFFFFFFF;
  AssignFile(F,'test.txt');
  ReWrite(F);
  Writeln(F,A);
  Writeln(F,B);
  CloseFile(F);
  AssignFile(F,'test.txt');
  ReSet(F);
  ReadLn(F,A);
{
Fails to compile on following line with message:
[DCC Fatal Error] Unit1.pas(42): E2158 System unit out of date or corrupted: missing 'Text.ReadUInt64'
}
  ReadLn(F,B);
  CloseFile(F);
end;

最佳答案

参见QC102876 。这是一个已知错误,报告为 Text.ReadUInt64 缺失,描述如下:

The compiler generates a call to Text.ReadUInt64, when an UInt64 should be read from a stream. The linker, however, complains that Text.ReadUInt64 is missing.

根据 QC 的说法,此问题(bug)已在 XE3(内部版本 #17.0.4625.53395)中得到解决。

关于delphi - 对 UInt64 感到困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15510876/

相关文章:

multithreading - 如何保持线程的消息泵 react 性

delphi - 如何更改默认的delphi停靠窗体标题高度?

delphi - 在 TThread 内创建窗口

delphi - 使用 TTime 作为 TDictionary 的键

Delphi XE2 : Fail using dcc32. exe编译简单程序

delphi - 如何动态创建与顶部对齐但在其他对齐控件之后的控件?

delphi - 如何将 TCanvas 包裹在现有的像素数据周围?

c++ - 如何与 numeric_limits<int64_t>::min() 进行比较

将32位 float 转换为64位uint64_t

c++ - 访问冲突转换为 void* 并返回