Search code examples
delphidelphi-2007record

Record file error


I am using Delphi 2007 and I am trying to make record type file. In Delphi 7 there were no problems for me.

Type
Kompiuteris = record
...
end;
Failas = file of Kompiuteris;

But in Delphi 2007 I get problem. Error says that: Type "Kompiuteris" needs finalization. So, what is wrong?


Solution

  • From the documentation:

    Certain types are treated specially by the compiler on an internal basis in that they must be correctly finalized to release any resources that they might currently own. Because the compiler cannot determine what type is actually stored in a record's variant section at runtime, it is not possible to guarantee that these special data types are correctly finalized.

    String is one of those data types which need finalization, and as such they cannot be stored in a File type.