incompactable指针类型传递的int类型为void(*)(无效)的参数coretelephony OBJÇ [英] incompactable pointer type passing int to parameter of type void(*)(void) in coretelephony obj c

查看:353
本文介绍了incompactable指针类型传递的int类型为void(*)(无效)的参数coretelephony OBJÇ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在coreTelephony.h定义的函数

The function defined in coreTelephony.h is

void _CTServerConnectionRegisterForNotification(CTServerConnectionRef,void *,void(*callback)(void));

然后我试图调用此函数

Then I tried to call this function

int x = 0; //placehoder for callback
_CTServerConnectionRegisterForNotification(conn,kCTCellMonitorUpdateNotification,&x);

它返回错误

兼容的指针类型传递int在coretelephony OBJ C型无效(*)(无效)的参数

incompatible pointer type passing int to parameter of type void(*)(void) in coretelephony obj c

我是什么失踪?

推荐答案

下面的第三个参数 _CTServerConnectionRegisterForNotification(),就是要一个指向有一个函数

Here, the third argument to _CTServerConnectionRegisterForNotification() is meant to be a pointer to a function having


  • 无效返回类型

  • 接受任何参数。

您不能在这种情况下通过的 INT 的地址。这是错误的,会导致未定义行为

You cannot pass the address of an int in that case. It is wrong and will cause undefined behavior.

这篇关于incompactable指针类型传递的int类型为void(*)(无效)的参数coretelephony OBJÇ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆