Name

Pascal Directive

Syntax

Subroutine declaration; pascal;

Description

The pascal directive tells the compiler to use Pascal calling conventions for the function or procedure. The caller of the subroutine pushes arguments onto the stack, starting with the leftmost argument. Before the subroutine returns, the subroutine pops the arguments from the stack.

Functions return ordinal values, pointers, and small records or sets in EAX and floating-point values on the FPU stack. Strings, dynamic arrays, Variants, and large records and sets are passed as a hidden var parameter. If the subroutine is a method, Self is the first parameter, and the hidden var parameter is the second, so these parameters are pushed first onto the stack.

Tips and Tricks

Don’t be deceived by the name. Delphi’s default calling convention is register, not pascal. The pascal convention is for backward compatibility, and should not be used except to interface with an archaic DLL.

See Also

CDecl Directive, Function Keyword, Procedure Keyword, Register Directive, SafeCall Directive, StdCall Directive

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.