Delphi Error – E2179 Only register calling convention allowed in OLE automation section

Delphi Compiler Error

E2179 Only register calling convention allowed in OLE automation section

Reason for the Error & Solution

You have specified an illegal calling convention on a method appearing in an ‘automated’ section of a class declaration.

program Produce;

  type
    Base = class
    automated
      procedure Method; cdecl;
    end;

  procedure Base.Method; cdecl;
  begin
  end;

begin
end.

The language specification disallows all calling conventions except ‘register’ in an OLE automation section. The offending statement is ‘cdecl’ in the above code.

program Solve;

  type
    Base = class
    automated
      procedure Method; register;
      procedure Method2;
    end;

  procedure Base.Method; register;
  begin
  end;

  procedure Base.Method2;
  begin
  end;

begin
end.

There are three solutions to this error. The first is to specify no calling convention on methods declared in an auto section. The second is to specify only the register calling convention. The third is to move the offending declaration out of the automation section.

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