Function pointers casting in C++

前端 未结 8 1411
星月不相逢
星月不相逢 2020-11-27 15:45

I have a void pointer returned by dlsym(), I want to call the function pointed by the void pointer. So I do a type conversion by casting:

void *gptr = dlsym(         


        
8条回答
  •  被撕碎了的回忆
    2020-11-27 16:21

    This compiles in Visual Studio without using reinterpret cast:

    void *ptr;
    int (*func)(void) = (int(*)(void))ptr;
    int num = func();
    

提交回复
热议问题