Calling Convention Options (BCC32)

From RAD Studio
Jump to: navigation, search

Go Up to BCC32


Calling conventions determine the calling sequences that the compiler generates for function calls. Calling conventions differ in the way that each one handles stack cleanup, order of parameters, case, and prefix of global identifiers.

You can set the calling convention of your project in the IDE from the C++ Compiler options page in Project > Options. You can also use the keyword of a calling convention on specific functions to override the default calling convention on those functions only.

Calling Convention Description Keyword Command-Line Switch

C

Underscores are generated, names are case sensitive, parameters are pushed right to left.

Functions can take a variable parameter list (the number of parameters does not need to be fixed).

This is the default calling convention of BCC32.

__cdecl

-pc
-p-

Pascal

Underscores are not generated, names are uppercase, the caller function has to clean the stack, the parameters are pushed left to right.

The resulting function calls are usually smaller and faster than those made with the C calling convention. Functions must pass the correct number and type of arguments.

__pascal

-p

Register (fastcall)

Passes the first three arguments (evaluated from left to right) that fit into EAX, EDX, ECX, and pushes the remaining arguments onto the stack from left to right.

__fastcall

-pm
-pr

Standard Call

Underscores are not generated, name case is preserved, callee function has to clean the stack, parameters are pushed right to left.

Functions must pass the correct number and type of arguments.

__stdcall

-pm

See Also