Calling Conventions When declares or functions, you can use one of the following instructions to specify the call agreement: Register, Pascal, CDECL, Stdcall, and SaFECALL. For example, function myfunction (x, y: real): real; cdecl; ... Call agreement determines the order of parameters to pass to routine, which also affects the use of parameters from the stack, the use of registers, and errors And exception handling. The default call agreement is register. • Register and Pascal calls the parameters from left to right, that is, the leftmost parameter is first calculated and passed, the rightmost parameter is finally calculated and transmitted; CDECL, STDCALL and SAFECALL calls from right to left pass parameters; • • In addition to the CDECL call, the process and function removes the parameters from the stack before returning, and uses CDECL, when the call is returned, the caller removes the parameters from the stack; • Register calls can use up to 3 CPU registers to pass parameters, and Other calls all use the stack delivery parameters; • SaFECALL call implements an exception "firewall", under Windows, it implements COM error notifications between processes. The following table summarizes the call agreement: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- --------- Indicate word -------------- Parameter sequence --------- Clean-Up ----------- ---- Use the register to pass the parameters? | -register --------------- Left-to-right --------- Routine ----------------- YES --------------------- || -pascal --------------- Left-to-right ---- ----- Routine ---------------------------------------- | -CDECL- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -No --------------------- | -stdcall ---------------- Right-to-left --- ------- Routine -------------------------------------- | -safeCall --------------- Right-to-Left ---------- Routine ------------------- -NO --------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- ------------------ The default Register call is the most effective because it usually avoids the Stack Frame (the method of accessing the publishing property must use register) When the function in the shared library written from the C / C is used, the CDECL is useful; in general, STDCALL and SAFECALL are recommended when the external code is called.