RAD Studio (Common)
ContentsIndex
PreviousUpNext
E2418: Type '%s' needs initialization - not allowed in variant record (Delphi)

Type needs initialization - not allowed in variant record. Variant records do not allow types that need initialization in their variant field list since each variant field references the same memory location. As an example, the following code will not compile because the array type needs to be initialized.

program Project3;

{$APPTYPE CONSOLE}

type
  TFoo = record
    case Boolean of
      True: (bar: Integer);
      False: (baz: array [0..2] of Integer);
  end;

end.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!