Pascal Calls

In Windows programs, you'll frequently see a function with the PASCAL keyword in front of the function name.

When a function is called from a C program, the compiler generates machine code that first pushes the function parameters on the stack and then calls the function with the assembly-language CALL instruction. The parameters are pushed on the stack from right to left.

When a routine is called from a Pascal program, the same events take place, only the parameters are passed to the stack from left to right.

Because the Pascal calling convention is somewhat more space efficient, all Windows functions are implemented using the Pascal calling sequence.

Within your program, all functions that Windows can call must be defined with the PASCAL keyword. Functions that Windows can call are the WinMain. function, callback function, and window functions.

For more information about using the PASCAL keyword in Windows programs, see the “Creating Windows Programs” section.