Function pointer and calling convention

Yulo picture Yulo · Jan 28, 2011 · Viewed 9.1k times · Source
float __stdcall (*pFunc)(float a, float b) = (float (__stdcall *)(float,float))0x411280;

How to declare a function pointer with calling convention? The above gives me an error.

Answer

namey picture namey · Jan 28, 2011

The trick is placing the __stdcall inside the parentheses like this:

float (__stdcall *pFunc)(float a, float b) = (float (__stdcall *)(float,float))0x411280;

Of course, you are recommended to use a typedef instead, but the same trick applies:

typedef float (__stdcall *FuncType)(float a, float b);