gpt4 book ai didi

delphi - DCC错误: published field is not a class or interface type

转载 作者:行者123 更新时间:2023-12-03 15:27:29 26 4
gpt4 key购买 nike

我不断收到以下 DCC 错误,已发布的字段“名称”不是以下类的类或接口(interface)类型。

  TGroup = class
name:string[32]; <<<========================
rwFeatures:TFeatures;
roFeatures:TFeatures;
levels:TLevels;
private

public
constructor Create;
procedure Read(var f:file);
procedure ReadOld(var f:file);
procedure Write(var f:file);
end;

这是什么意思?

最佳答案

该类是用 Emit runtime type information 编译的设置已启用。当使用运行时类型信息编译类时,默认可见性为published。这意味着短字符串字段已已发布。并且不允许发布短字符串字段。

documentation说:

Fields can be published only if they are of a class or interface type.

这是一个相当严格的要求。例如,这意味着您无法发布整数或 bool 字段。

我怀疑此限制是因为已发布字段的主要用途是对象引用。想想表单上的组件。

使用以下选项之一解决问题:

  1. 不要发出此类的运行时类型信息。
  2. 公开而不是发布短字符串字段。
  3. 使用属性而不是字段。

关于delphi - DCC错误: published field is not a class or interface type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13941082/

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