Malloc 指针数组错误
我有以下代码:
interface ** rInterfaces[MAX_REACTANS];
_reaction->rInterfaces = (interface **)malloc(MAX_REACTANS * sizeof(interface *));
我收到一条错误消息:
error: incompatible types when assigning to type ‘struct interface **[10]’ from type ‘struct interface **’
我不知道为什么会收到此消息。任何帮助将不胜感激。
I have the following code:
interface ** rInterfaces[MAX_REACTANS];
_reaction->rInterfaces = (interface **)malloc(MAX_REACTANS * sizeof(interface *));
I am getting an error saying:
error: incompatible types when assigning to type ‘struct interface **[10]’ from type ‘struct interface **’
I don't know why I am getting this. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的
malloc
判断,您需要一个指向接口指针的指针。从声明中删除[MAX_REACTANS]
。您还可以删除interface **
强制转换。Judging by your
malloc
you want a pointer to a pointer to an interface. Drop[MAX_REACTANS]
from your declaration. You can also drop theinterface **
cast.