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.