float __stdcall (*pFunc)(float a, float b) = (float (__stdcall *)(float,float))0x411280;
How to declare a function pointer with calling convention? The
__fastcall
is the optimized one (fastest calling convention) but not used for an unknown reason
Try:
int (__fastcall *myfunction)(int,float);
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);
int (__cdecl **func)()
is the most accepted form by compilers. Some compilers accept int __cdecl (**func)(int)
and int (**__cdecl func)(int)
or even int (*__cdecl *func)(int)
. Clang accepts all 3 forms and correctly interprets them as the type int ((**))(int) __attribute__((cdecl))
Introducing a const
pointer on clang also does not change the picture and any arrangement is accepted so long as const is after the pointer
const int __cdecl (*const func)();
const int (__cdecl *const func)();
const int (*const __cdecl func)();