作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试这样做:
int (*p)(void);
int *i;
...
p = (int *(void))i;
但它会导致语法错误:
error: cast specifies function type
这里有什么问题吗?
最佳答案
在这种情况下你应该尊重错误。您不得将指向函数的指针转换为 int 指针或其他方式。这可能会导致未定义的行为。
如果你坚持的话,语法应该是:
p = (int (*)(void))i;
关于c - 如何将 int* 转换为 int (*p)(void)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6816938/
我是一名优秀的程序员,十分优秀!