How to correctly assign a pointer returned by dlsym into a variable of function pointer type?

前端 未结 6 1024
悲&欢浪女
悲&欢浪女 2020-12-31 01:00

I am trying to use dlopen() and dlsym() in my code and compile it with gcc.

Here is the first file.

/* main.c          


        
6条回答
  •  無奈伤痛
    2020-12-31 01:24

    This made my code sufficiently pedantic:

    *(void**)(&func_ptr) = dlsym(handle, "function_name");
    

    (I found it here http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html)

提交回复
热议问题