Scenario One: First look at the use of Windows under development:
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
Here is a callback, go to the definition look at
#elif (_msc_ver >= 800) | | Defined (_stdcall_supported) #define CALLBACK __stdcall#define WINAPI __stdcall ...
From the above can also be seen under the Windows platform WINAPI and Callbcak is actually consistent;
Scenario Two: In addition we know that when using the DUMPBIN DLL symbol name, assuming that there is an add function, output will be like [email protected]@[email protected], if you add the extern "C" characters, The function symbol of the output is the name of the previously defined add function, which involves the function call problem, because different languages and compiler platform, the Convention is not the same, for example, the function of the formal parameters, the default is pressed into the stack, some from left to right press, some from the right to the left, the different standards are not the same, So if there is an error in the invocation, you must indicate which method is called so that the compiler can recognize it correctly.
So what's the difference between them?
1) First of all, the C call standard is __cdecl, the use of the stack order, ...
While Delphi is using the Pascal call Standard, that is, the standard contract stdcall, is also the default use of Windows Convention, that is, under the Windows platform WINAPI, Callbcak, stdcall is in fact consistent
2) __stdcall and __cdecl are two different calling conventions that define the order in which the function parameters are stacked, whether the call function or the called function pops up the stack, and the method that produces the function decorated name
3) in Windows programs, the callback function must follow the __stdcall calling convention, so the use of callback, of course, can also be directly used __stdcall, mainly to facilitate the separation
Note: About the stacking order, remember the front in the book on the embedded aspects of the order of the press in the stack, mainly they use the assembly, the specific parameters must be pressed into the relevant registers, and then refer to the time can be corresponding, look back, and then do in-depth explanation