通过其他许多与此相关的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