通過其他許多與此相關的SO帖子,但沒有人能夠幫助我。所以,我有以下結構定義:錯誤:取消引用指向不完整類型的指針
typedef struct
{
int created;
double data;
int timeLeft;
int destination;
}dataPacket;
typedef struct
{
dataPacket *array;
int currIndex;
int firstIndex;
int nextTick;
int maxLength;
int length;
int stime;
int total;
}packetBuffer;
typedef struct{
int mac;
struct wire *lconnection;
struct wire *rconnection;
int numRecieved;
struct packetBuffer *buffer;
int i;
int backoff;
}node;
typedef struct{
float length;
float speed;
int busy;
struct dataPacket *currPacket;
struct node *lnode;
struct node *rnode;
}wire;
然後我嘗試使用以下功能:
int sendPacket(node *n, int tick)
{
if(n->buffer->length > 0)
{
if(n->backoff <= 0)
{
if (n->lconnection->busy != 0 || n->lconnection->busy != 0)
{
n->i++;
n->backoff = (512/W * genrand()*(pow(2,n->i)-1))/TICK_LENGTH;
}
else
{
n->lconnection->busy = 1;
n->rconnection->busy = 1;
n->lconnection->currPacket = n->buffer[n->buffer->currIndex];
n->rconnection->currPacket = n->buffer[n->buffer->currIndex];
}
}
else
{
n->backoff--;
}
}
}
我得到的稱號,每次描述的錯誤我嘗試訪問緩衝區,lconnection或rconnection的成員。
'if(n-> lconnection-> busy!= 0 || n-> lconnection-> busy!= 0)'...爲什麼有一個具有相同條件的'或'語句? – d0rmLife 2013-03-11 18:13:19
@ d0rmLife:推測RHS應該參考'rconnection' – 2013-03-11 18:15:22
@ KeithThompson ...毫無疑問......!) – d0rmLife 2013-03-11 18:16:20