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