HomeDelphiDelphi Error – E2210 ‘%s’ directive not allowed in in interface type

Delphi Error – E2210 ‘%s’ directive not allowed in in interface type

Delphi Compiler Error

E2210 ‘%s’ directive not allowed in in interface type

Reason for the Error & Solution

A directive was encountered during the parsing of an interface which is not allowed.

program Produce;
  type
    IBaseIntf = interface
    private
      procedure fnord(x, y, z : Integer);
    end;

begin
end.

In this example, the compiler gives an error when it encounters the private directive, as it is not allowed in interface types.

program Solve;
  type
    IBaseIntf = interface
      procedure fnord(x, y, z : Integer);
    end;

    TBaseClass = class (TInterfacedObject, IBaseIntf)
    private
      procedure fnord(x, y, z : Integer);
    end;

  procedure TBaseClass.fnord(x, y, z : Integer);
  begin
  end;
begin
end.

The only solution to this problem is to remove the offending directive from the interface definition. While interfaces do not actually support these directives, you can place the implementing method into the desired visibility section. In this example, placing the TBaseClass.fnord procedure into a private section should have the desired results.

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