Delphi - 关于错误E2154 Type '%s' needs finalization - not allowed in variant record
2010-12-29 09:40
525 查看
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也会造成这个错误.
技术交流,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
- 关于C#中的错误:The type 'X' does not exists in the "Y"
- Delphi - 关于错误E2002 File Type is not allowed here
- 关于Could not find a storyboard named 'Me' in bundle NSBundle崩溃错误
- Delphi - 关于错误E2002 File Type is not allowed here
- error C3872: '0x3000': this character is not allowed in an identifier.怎么解决?
- mysql错误1130,具体描述如下ERROR 1130 Host 'localhost' is not allowed to connect to this MySQL
- Service 'china' of type 'MapServer' does not exist or is inaccessible
- 关于使用CursorAdapter()时出现“column '_id' does not exist”错误的说明及解决方案
- 处理关于Component 'TABCTL32.OCX' or one of its dependencies not correctyly registered:类的错误:
- response错误:Request header field Content-Type is not allowed by Access-Control-Allow-Headers in prefl
- Anaconda下import caffe出现错误TypeError: 'module' object is not callable
- JNI_OnLoad编译错误:request for member 'GetEnv' in something not a structure or union
- error C3872: '0x3000': this character is not allowed in an identifier 解决方法
- VS错误error C3872: '0x3000': this character is not allowed in an identifier
- error C2533: ' ::{ctor}' : constructors not allowed a return type
- python socket send 错误:TypeError: 'str' does not support the buffer interface
- VS:error C3872: '0xe044': this character is not allowed in an identifier解决方法
- [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify uni
- code signing is required for product type 'Application' in SDK 'iOS 9.0'错误