0
所以我一直歌廳錯誤「的東西不是一個結構或聯合」
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);
}
我想我的主要問題是什麼原因導致這樣的錯誤
int q = rand()%1000 + 1;現在q是一個int:3 – User 2015-03-30 17:52:05