7.4 Pascal Calling Convention for Microsoft Windows
If the Microsoft C compiler is being used to compile and link C programs, there are two possibilities to call the functions:
- "Pascal-Calling-Convention"
- "C-Calling-Convention"
The normal mode for Microsoft C compiler is C Calling Convention, the normal mode for Microsoft Windows is Pascal Calling Convention.
The difference between these two modes is
- the sequence of pushing the arguments onto the stack, and
- the type of stack restoring (calling or called function).
Since both Microsoft Windows and DM work internally with Pascal Calling Convention, all functions with no specified calling convention are called by the Pascal Calling Convention.
The calling convention can be set with one of the following possibilities:
Explicit Declaration
The specified calling convention is used.
Example
function C integer foo (integer); |
C-Calling-Convention |
function pascal integer foo (integer); |
Pascal-Calling-Convention |
Implicit Declaration
DM assumes internally the Pascal Calling Convention.
Example
function integer foo (integer); |
Pascal-Calling-Convention |
Note
Do not declare the functions by yourself! You can have DM generate function prototypes with the command given below. The file "protofile" should be linked in each module (see example) in which functions are called by the DM and FunctionMap is defined.
Example
idm +writeproto <protofile> <dialogscript>
(Please note that "idm" for MS Windows has to be started on MS Windows!)
Note
If undefinable symbols occur during linking, the calling conventions might be responsible.