How to print the address of a function?

前端 未结 4 620
旧时难觅i
旧时难觅i 2020-11-29 11:18

I let gcc compile the following example using -Wall -pedantic:

#include 

int main(void)
{
  printf(\"main: %p\\n\",         


        
4条回答
  •  庸人自扰
    2020-11-29 11:36

    While converting a function pointer to a void pointer is technically dangerous, converting function pointers to void pointers is used in the POSIX standard, so it is almost sure to work on most compilers.

    Look up dlsym().

提交回复
热议问题