Function pointer and calling convention

前端 未结 3 1959
栀梦
栀梦 2021-02-04 04:24
float __stdcall (*pFunc)(float a, float b) = (float (__stdcall *)(float,float))0x411280;

How to declare a function pointer with calling convention? The

3条回答
  •  执笔经年
    2021-02-04 04:53

    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)();
    

提交回复
热议问题