Delphi Error – E2270 Published property getters and setters must have %s calling convention

Delphi Compiler Error

E2270 Published property getters and setters must have %s calling convention

Reason for the Error & Solution

A property appearing in a published section has a getter or setter procedure that does not have the correct calling convention.

unit Produce;
interface
  type
    Base = class
    public
      function getter : Integer; cdecl;
    published
      property Value : Integer read getter;
    end;

implementation
function Base.getter : Integer;
begin getter := 0;
end;

end.


This example declares the getter function getter for the published property Value to be of cdecl calling convention, which produces the error.

unit Solve;
interface
  type
    Base = class
    public
      function getter : Integer;
    published
      property Value : Integer read getter;
    end;

implementation
function Base.getter : Integer;
begin getter := 0;
end;

end.


The only solution to this problem is to declare the getter function to match the correct calling convention, which is the default. As can be seen in this example, no calling convention is specified.

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...