Casting a function pointer to another type

后端 未结 7 1475
终归单人心
终归单人心 2020-11-22 08:07

Let\'s say I have a function that accepts a void (*)(void*) function pointer for use as a callback:

void do_stuff(void (*callback_fp)(void*), vo         


        
7条回答
  •  不要未来只要你来
    2020-11-22 08:28

    If you think about the way function calls work in C/C++, they push certain items on the stack, jump to the new code location, execute, then pop the stack on return. If your function pointers describe functions with the same return type and the same number/size of arguments, you should be okay.

    Thus, I think you should be able to do so safely.

提交回复
热议问题