Reputation: 49
I have a struct defined as:
typedef struct _InstNode{
InstInfo* instinfo;
struct _InstNode *dep1;
struct _InstNode *dep2;
bool is_exit;
bool is_entry;
unsigned inst_latency;
unsigned depth_latency;
} InstNode;
and this is instnode_array :
InstNode *instnode_array;
instnode_array = (InstNode*)malloc(sizeof(InstNode)*numOfInsts);
Now I'm trying to do the following:-
instnode_array[i].dep1 = instnode_array[j];
I'm getting this error:
incompatible types when assigning to type
'struct _InstNode *'
from type'InstNode
{akastruct _InstNode
}'instnode_array[i].dep1 = instnode_array[j];
Upvotes: 1
Views: 77
Reputation: 134326
TL;DR Note Honor the data types.
instnode_array[j]
gives you a struct _InstNode
whereas, dep1
is of type struct _InstNode *
.
You may want to write
instnode_array[i].dep1 = &(instnode_array[j]);
if that make sense to you.
Upvotes: 3