The value of ESP was not properly saved across a function call
I'm working with a cross-platform library which defines a function to obtain function addresses from a shared object (i.e. a DLL on Windows). Here's my modified version of the function which works (albeit only on Windows of course):-
typedef void (*SuilVoidFunc)(void);
/** dlsym wrapper to return a function pointer */
static inline SuilVoidFunc
suil_dlfunc(void* handle, const char* symbol)
return (SuilVoidFunc)GetProcAddress((HMODULE)handle, symbol);
Now, here's the original (cross-platform) version which is giving me a run time error on Windows:-
That original version fails at the final return line. The error message says "The value of ESP was not properly saved across a function call".
I'm assuming there's a problem with the declaration of VoidFuncGetter (i.e. it'll assume that the caling convention for GetProcAddress() is cdecl when in fact, it's stdcall). What's the most elegant way to fix this and still keep cross-platform compatibility?
"A problem well stated is a problem half solved.” - Charles F. Kettering