简体   繁体   English

Malloc指针数组错误

[英]Malloc array of pointers error

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. 任何帮助,将不胜感激。

Judging by your malloc you want a pointer to a pointer to an interface. 根据您的malloc判断,您需要一个指向接口的指针。 Drop [MAX_REACTANS] from your declaration. 从您的声明中删除[MAX_REACTANS] You can also drop the interface ** cast. 您还可以删除interface ** cast。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM