Name

CDecl Directive

Syntax

Subroutine declaration; cdecl;

Description

The cdecl directive tells the compiler to use C-style calling conventions for the function or procedure. The caller of the subroutine pushes arguments onto the stack, starting with the rightmost argument. After the subroutine returns, the caller 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. This hidden parameter is the first parameter, so it is pushed last onto the stack. If the subroutine is a method, Self is pushed just before the function’s var result (if one is needed).

See Also

Function Keyword, Pascal Directive, 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.