I get the following error when my app returns:
"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."
But only if two things are true:
1) You start the app outside of the IDE and then attach to it when it breaks.
2) You call a function implemented in a lib.
This code will reproduce the error:
int __stdcall
WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, char* lpCmdLine, int nCmdShow )
{
__debugbreak();
TestFn();
return 0;
}
(Code for lib not shown, but it would just implement 'TestFn()')
What's going on here?
edit:
Decided to show the code for the lib in case I'm doing that wrong:
test.h
bool TestFn( );
test.cpp
bool TestFn( )
{
return true;
}