In a file named test.dll, there is a Max () function definition is:
#ifdef BUILD_DLL #define DLL_EXPORT __declspec(dllexport) __stdcall #else #define DLL_EXPORT __declspec(dllimport) __stdcall #endif int DLL_EXPORT Max(int x, int y);
When I c in the program, set a pointer type to a function: when int (* func) (int, int)
HMODULE h = LoadLibrary("test.dll"); if(h) { int (*func)(int, int) =(int (*)(int, int))GetProcAddress(h, "Max"); printf("max(1,2):%d\n", func(1,2)); }
After calling this function func (1,2), windows not immediately error, when the program exits windows will complain:
If the function pointer when defined, plus WINAPI, there is no problem:
#define WINAPI __stdcall HMODULE h = LoadLibrary("test.dll"); if(h) { int (WINAPI *func)(int, int) =(int (WINAPI *)(int, int))GetProcAddress(h, "Max"); printf("max(1,2):%d\n", func(1,2)); }
Finally, my guess is that before the code is not added to the reasons WINAPI after the program exits, windows will complain, should be related to the dll in the __stdcall.
It should be involved in cleanup stack (STACK) in question.
Relevant information:
_cdecl 和_stdcall:https://www.cnblogs.com/52yixin/archive/2011/06/29/2093634.html
_stdcall 与 _cdecl:https://blog.csdn.net/nightwizard2030/article/details/86596635
_stdcall differs _cdecl: https://blog.csdn.net/leehong2005/article/details/8607536
Famous recommendation: Hanabusa Iraq Ruo Xuan Millennium Ma Pui Yan