gpt4 book ai didi

delphi - Delphi 中的 System.String 到底是什么?

转载 作者:行者123 更新时间:2023-12-03 15:22:56 25 4
gpt4 key购买 nike

我维护了一些相当旧的 Delphi 代码,它们在特定单元中使用 EmptyString

编译器将其解析为

costant EmptyString = '' - from System.string

现在我的硬盘中没有 System.string.pas 文件或 .dcu,所以我无法了解更多信息。

我发现

C:\Program Files (x86)\Embarcadero\Studio\17.0\source\rtl\sys\system.SysUtils.pas

另一个类似的常数:

{ Empty string and null string pointer. These constants are provided for
backwards compatibility only. }

EmptyStr: string = '';
{$IFNDEF NEXTGEN}
NullStr: PString = @EmptyStr;

乍一看,EmptyStrEmptyString 似乎仅在过去使用过,因此它们不知何故已被弃用,因此最好使用 ''直接或在应用程序中定义常量来重新定义它们。

现在升级第 3 方组件后,我意识到 EmptyString 不再解析。

我的问题是:System.String 到底是什么?为什么rtl中没有对应的.pas文件?

我用谷歌搜索没有成功。

谢谢。

最佳答案

System.String类型是String正式定义于 System单位。

string 类型实际上是 System.UnicodeString 的别名。类型。文档称其定义为:

type String = UnicodeString;

反过来,UnicodeString 的文档说:

type UnicodeString = { built-in type };

没有 Pascal 代码来定义该类型,因为它是内置内在类型。所有内置类型都被正式视为在 System 单元中声明,即使您无法在该单元的 Pascal 源代码中看到它们的声明。

关于delphi - Delphi 中的 System.String 到底是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54476982/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com