Reputation: 133
I'm new in Delphi and I was migrating a very old Delphi project to Embarcadero RAD Studio 2010. I found a problem using strings. Here is the code:
ProgramaResultadosType = record
Version: string;
TituloPrincipal : string;
BloquesResultados : VectorBloquesResultadosType;
end;
FileOfProgramaResultadosType = file of ProgramaResultadosType;
And the error...
"E2155 Type '%s' needs finalization - not allowed in file type"
I know it's a well-known error for many delphi developers when you don't specify the string size.
Basically I would like to deactivate Huge strings directive like older versions of RAD Studio, but I can't find out in the 2010 version.
Upvotes: 5
Views: 538
Reputation: 43033
Just use instead:
ProgramaResultadosType = record
Version: shortstring;
TituloPrincipal : shortstring;
BloquesResultados : VectorBloquesResultadosType;
end;
But be aware that:
string
type: you should better use another explicit string
variable just after having read the shortstring
content;string
is an Unicode string: so you may lose some data when writing into a shortstring
(which is an Ansi string) from an UnicodeString
;ProgramaResultadosType = packed record
could be necessary if your application is very very old (default alignment changed around Delphi 4, AFAIR).So you may have to:
Worth reading when converting an existing application to newer Unicode version of Delphi:
Upvotes: 10