简体   繁体   中英

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. Drop [MAX_REACTANS] from your declaration. You can also drop the interface ** cast.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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