Run-time Check Failure #0-the value of ESP is not properly saved across a function call. This is

Source: Internet
Author: User
Defining pointer functions
typedef int (*DLLFUNC) (int,int);


int main (void)
{
DllFunc DllFunc;
HINSTANCE hinstance = LoadLibrary ("Main.dll");
Try
//{
if (hinstance!= NULL)
{
DllFunc = (dllfunc) GetProcAddress (hinstance, "Max");
if (DllFunc!= NULL)
{
cout << DllFunc (2,9) << Endl;
}
}
}catch (Exception & ex)
//{
FreeLibrary (HINSTANCE);
// }
cout << Min (199,299) << Endl;
cout << Max (199,299) << Endl;
return 0;

}


When dynamically invoking a DLL function, the prompt run-time Check failure #0-the value of ESP is not properly saved across a function call. Error

Reason: Because the invoked DLL is _stdcall invoked, C + + defaults are _DECLSPEC caused by the use of the

Modify the pointer function to _stdcall. typedef INT (_stdcall * dllfunc) (int, int);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.