Delphi - 关于错误E2154 Type '%s' needs finalization - not allowed in variant record
来源:互联网 发布:阿里云幕布的申请 编辑:程序博客网 时间:2024/06/05 22:58
Delphi - 关于错误E2154 Type '%s' needs finalization - not allowed in variant record
技术交流,DH讲解.
这个错误主要出现在结构体的变体部分.当结构体变体部分里面包含一个不定长的数据时,编译器就会报出错误来.
我们来看下:
view sourceprint?
type
Data = record
case kind:Char of
'A': (str : String);
end;
我们知道变体结构体会在编译的时候确定这个结构体的大小.但是这样它就确定不了了.
那么要怎么修改呢?
1 要么有不定长数据的时候不要放在变体部分.如:
view sourceprint?
type
Data = record
str : String;
end;
2 改成指针
如改成PString.不推荐.结构体没有Destroy方法,有时候我们如果手动分配了空间,它释放不了的.
除了String会这样,还有Array Of Type也会造成这个错误.
- Delphi - 关于错误E2154 Type '%s' needs finalization - not allowed in variant record
- Delphi - 关于错误E2002 File Type is not allowed here
- 错误:constructors not allowed a return type
- 错误:constructors not allowed a return type
- constructors not allowed a return type错误
- 错误:#{...} is not allowed in template text
- Content is not allowed in prolog.错误
- 编译错误:constructors not allowed a return type
- 编译错误:constructors not allowed a return type
- pointer to incomplete class type is not allowed是什么错误?
- pointer to incomplete class type is not allowed 错误
- Android AsyncHttpClient 下载文件 Content-Type not allowed! 错误
- constructors not allowed a return type错误问题
- 【BUG记录】Content is not allowed in prolog错误
- Write operations are not allowed in read-only mode错误
- Content is not allowed in prolog错误解决
- incomplete type is not allowed
- 关于SVN的405错误Server sent unexpected return value (405 Method Not Allowed) in response to
- /LGC窗口管理/组合窗口管理器
- WPF Binding
- activeReport_开发
- think about how to make the function close to really world
- spring中scope设置的疑问(解决)
- Delphi - 关于错误E2154 Type '%s' needs finalization - not allowed in variant record
- 粗糙集用于数据约简和提取决策规则C/C++(1)
- Snake算法
- ZOJ 2539 Energy Minimization
- activereport报表控件的详细使用说明
- fatal error C1083: 无法打开包含文件:“iostream.h”: No such file or directory
- asp.net 中的静态变量 (小知识)
- C_.NET下使用水晶报表
- VC中判断目录,文件是否存在,创建目录的方法