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):-

Code:
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:-

Code:
typedef void (*SuilVoidFunc)(void);
#define dlsym GetProcAddress

/** dlsym wrapper to return a function pointer */
static inline SuilVoidFunc
suil_dlfunc(void* handle, const char* symbol)
{
	typedef SuilVoidFunc (*VoidFuncGetter)(void*, const char*);
	VoidFuncGetter dlfunc = (VoidFuncGetter)dlsym;
	return dlfunc(handle, symbol);
}
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?