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

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 X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...