【问题标题】:Malloc array of pointers errorMalloc 指针数组错误
【发布时间】:2012-03-14 10:34:39
【问题描述】:

我有以下代码:

    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 **’

我不知道我为什么会得到这个。任何帮助将不胜感激。

【问题讨论】:

  • 什么是_reaction_reaction->rInterfaces 是什么?

标签: c arrays pointers memory-management malloc


【解决方案1】:

根据您的malloc 判断,您需要一个指向接口指针的指针。从您的声明中删除[MAX_REACTANS]。您也可以放弃 interface ** 演员表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-04
    相关资源
    最近更新 更多