编码时如何获取自定义函数执行地址?

时间:2023-02-13 15:06:13

Simple code, eg:

简单的代码,例如:

void* print_my_address() {
    printf("%p\n", .../* get the execution address of print_my_address */)
}

Thanks!

PS: gcc v4.7 Can I get the address by compiler?

PS:gcc v4.7我可以通过编译器获取地址吗?

1 个解决方案

#1


4  

The same way you'd do it for any other regular variable:

对于任何其他常规变量,您也可以这样做:

void print_my_address() 
{
    printf("%p\n", &print_my_address);
}

#1


4  

The same way you'd do it for any other regular variable:

对于任何其他常规变量,您也可以这样做:

void print_my_address() 
{
    printf("%p\n", &print_my_address);
}