Delphi Error – E2188 Published property ‘%s’ cannot be of type %s

Delphi Compiler Error

E2188 Published property ‘%s’ cannot be of type %s

Reason for the Error & Solution

Published properties must be an ordinal type, Single, Double, Extended, Comp, a string type, a set type which fits in 32 bits, or a method pointer type. When any other property type is encountered in a published section, the compiler will remove the published attribute -$M+

(*$TYPEINFO ON*)
program Produce;

  type
    TitleArr = array [0..24] of char;
    NamePlate = class
    private
      titleStr : TitleArr;
    published
      property Title : TitleArr read titleStr write titleStr;
    end;

begin
end.

An error is induced because an array is not one of the data types which can be published.

(*$TYPEINFO ON*)
program Solve;

  type
    TitleArr = integer;
    NamePlate = class
      titleStr : TitleArr;
    published
      property Title : TitleArr read titleStr write titleStr;
    end;

begin
end.

Moving the property declaration out of the published section will avoid this error. Another alternative, as in this example, is to change the type of the property to be something that can actually be published.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...