相关疑难解决方法(0)

如何打印功能的地址?

gcc使用以下方法编译以下示例-Wall -pedantic:

#include <stdio.h>

int main(void)
{
  printf("main: %p\n", main); /* line 5 */
  printf("main: %p\n", (void*) main); /* line 6 */

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

我明白了:

main.c:5: warning: format ‘%p’ expects type ‘void *’, but argument 2 has type ‘int (*)()’
main.c:6: warning: ISO C forbids conversion of function pointer to object pointer type
Run Code Online (Sandbox Code Playgroud)

第5行让我更改了第6行中的代码.

在打印功能的地址时删除警告我错过了什么?

c linux gcc function-pointers gcc-warning

16
推荐指数
3
解决办法
1万
查看次数

标签 统计

c ×1

function-pointers ×1

gcc ×1

gcc-warning ×1

linux ×1