void xGetFunctionAddress(void* FunctionDefinition, std::string FunctionName)
{
*static_cast<FARPROC*>(FunctionDefinition) = xProcAddress(Module, FunctionName.c_str());
}
In the above code, I'm trying to get rid of that FARPROC*
to make it cross-platform. However, if I cast to long long int (*)()
, it gives me the error that it cannot statically cast to that. So when I typedef it, it works:
Ex:
//This works:
void xGetFunctionAddress(void* FunctionDefinition, std::string FunctionName)
{
typedef __stdcall long long int (*Ptr)();
*static_cast<Ptr*>(FunctionDefinition) = GetProcAddress(Module, FunctionName.c_str());
}
//This doesn't:
void xGetFunctionAddress(void* FunctionDefinition, std::string FunctionName)
{
*static_cast<long long int(*)()>(FunctionDefinition) = GetProcAddress(Module, FunctionName.c_str());
}
What am I doing wrong in the second example? :S