Call a void* as a function without declaring a function pointer

后端 未结 3 518
深忆病人
深忆病人 2021-02-05 15:32

I\'ve searched but couldn\'t find any results (my terminology may be off) so forgive me if this has been asked before.

I was wondering if there is an easy way to call a

3条回答
  •  别跟我提以往
    2021-02-05 16:14

    I get awfully confused when casting to function types. It's easier and more readable to typedef the function pointer type:

    void *ptr = ...;
    typedef void (*void_f)(void);
    ((void_f)ptr)();
    

提交回复
热议问题