1. _ cdecl
(1) c Declaration stands for c Declaration, indicating the default function calling method of C language. It is actually the default function of C ++.
Number of call methods.
(2). All parameters are pushed to the stack from right to left. These parameters are cleared by the caller, which is called manual stack clearing. Details: Call
Party A's function call-> execution of the called function-> return of the result of the called function-> the caller clears the adjustment stack. (3). The called function does not require the caller to pass many parameters. The caller must pass too many or too few parameters, or even completely
Different parameters do not produce compilation errors. In general, the number of parameters of a function is variable (just like that of a printf function), because only the caller knows how many parameters it passes to the called function, and the stack can be adjusted properly at the end of the call.
(4). Because a piece of code to adjust the stack needs to be generated for each call, the final file generated is large.
2. _ stdcall (callback/winapi)
(1). It is short for standard call. To use this call method, add _ stdcall to the function name _
Win32 API should be a _ stdcall call rule. If a DLL written in VC ++ is to be called by a program written in other languages, the function call method should be declared as _ stdcall. winapi adopts this method.
(2). All parameters are pushed to the stack from right to left. If it is a member of the call class, the last one is the this pointer. Specifically, call the function of the caller-> execute the called function-> clear the adjustment stack of the called party-> return the result of the called function.
(3 ). the parameters in the stack are cleared after the called function returns. The command is retn X, and X indicates the number of bytes occupied by the parameter, the CPU automatically pops up X bytes of stack space after ret. It is called automatic stack clearing. (4) the number of parameters must be determined when the function is compiled, and the caller must strictly control the generation of parameters.
More than, not less; otherwise, an error will occur. In general, the number of parameters of a function cannot be variable. It is modified from _ cdecl. _ stdcall does not support variable parameters, and stack clearing is the responsibility of the caller. Others are the same (5 ). because you only need to generate a code to adjust the stack where the function is called, the final file generated is small.