A distinction between the declaration and use of a procedure has been discovered by the compiler.
program Produce; type ProcedureParm0 = procedure; stdcall; ProcedureParm1 = procedure(VAR x : Integer); procedure WrongConvention; register; begin end; procedure WrongParms(x, y, z : Integer); begin end; procedure TakesParm0(p : ProcedureParm0); begin end; procedure TakesParm1(p : ProcedureParm1); begin end; begin TakesParm0(WrongConvention); TakesParm1(WrongParms); end.
Because the type ‘ProcedureParm0′ expects a’stdcall’ procedure, but ‘WrongConvention’ is declared with the’register’ calling convention, the call to ‘TakesParm0’ will result in an error. Similarly, because the parameter lists do not match, the call to ‘TakesParm1’ will fail.
program Solve; type ProcedureParm0 = procedure; stdcall; ProcedureParm1 = procedure(VAR x : Integer); procedure RightConvention; stdcall; begin end; procedure RightParms(VAR x : Integer); begin end; procedure TakesParm0(p : ProcedureParm0); begin end; procedure TakesParm1(p : ProcedureParm1); begin end; begin TakesParm0(RightConvention); TakesParm1(RightParms); end.
Both of these issues can be solved by ensuring that the calling convention or parameter lists match the declaration.
Leave a Reply