mihajlv
mihajlv

Reputation: 2315

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.

Upvotes: 0

Views: 136

Answers (1)

cnicutar
cnicutar

Reputation: 182639

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.

Upvotes: 3

Related Questions