[英]Pointer assignment error C
我有一個結構定義為:
typedef struct _InstNode{
InstInfo* instinfo;
struct _InstNode *dep1;
struct _InstNode *dep2;
bool is_exit;
bool is_entry;
unsigned inst_latency;
unsigned depth_latency;
} InstNode;
這是instnode_array:
InstNode *instnode_array;
instnode_array = (InstNode*)malloc(sizeof(InstNode)*numOfInsts);
現在,我正在嘗試執行以下操作:
instnode_array[i].dep1 = instnode_array[j];
我收到此錯誤:
從類型
'InstNode
{akastruct _InstNode
}'分配給類型'struct _InstNode *'
時不兼容的類型instnode_array[i].dep1 = instnode_array[j];
TL; DR 注意 遵守數據類型。
instnode_array[j]
為您提供了一個struct _InstNode
而dep1
是struct _InstNode *
類型。
你可能想寫
instnode_array[i].dep1 = &(instnode_array[j]);
如果這對您有意義。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.