C &引用;不是结构或联盟的东西;
所以我一直犯错误C &引用;不是结构或联盟的东西;,c,struct,C,Struct,所以我一直犯错误 request for member ‘iArray’ in something not a structure or union int place = q.iArray[q.in];//reorder 我有另一个功能,这个调用工作得很完美,但出于某种原因,在我的消费者功能中,它产生了这个调用 我的cdoe是: typedef struct _struct_x { int iArray[MAX_COUNT]; int in; int out; } s
request for member ‘iArray’ in something not a structure or union
int place = q.iArray[q.in];//reorder
我有另一个功能,这个调用工作得很完美,但出于某种原因,在我的消费者功能中,它产生了这个调用
我的cdoe是:
typedef struct _struct_x
{
int iArray[MAX_COUNT];
int in;
int out;
} struct_x;
struct_x q;
void * consumer (void *t)
{
int tid = * (int *)t;
printf ("consumer started\n");
while (!done)
{
printf("IM IN THIS LOOP\n");
int q = rand() % 1000 + 1;
pthread_mutex_lock (&count_mutex);
usleep(q*1000);
if (count <= 0)
{
//its empty..
}
else{
int place = q.iArray[q.in];//reorder
q.in = (q.in+1)%MAX_COUNT;
int facto = 0;
printf("Consumer removed %d, computed %d != &d, queue size = %d\n",place,place,facto,count);
count--;
}
pthread_mutex_unlock (&count_mutex);
}
printf ("T2[%d] thread done.\n", tid);
pthread_exit (NULL);
}
typedef struct\u struct\u x
{
int iArray[最大计数];
int-in;
指出;
}结构x;
结构xq;
void*consumer(void*t)
{
int-tid=*(int*)t;
printf(“消费者启动\n”);
而(!完成)
{
printf(“此循环中的IM\n”);
int q=rand()%1000+1;
pthread_mutex_lock(&count_mutex);
usleep(q*1000);
如果(count您已在此行中将q重新定义为整数-
int q = rand() % 1000 + 1;
这是导致编译错误的原因。int q=rand()%1000+1;现在q是int:3oh哇,愚蠢的我盯着它看了这么久,一定是错过了。谢谢你,好心的先生。