C - "something not a structure or union"



所以我一直在获取错误

 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 startedn");
   while (!done)
    {
        printf("IM IN THIS LOOPn");
        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 = %dn",place,place,facto,count);
                count--;
            }   
        pthread_mutex_unlock (&count_mutex);
    }
  printf ("T2[%d] thread done.n", tid);
  pthread_exit (NULL);
}

我想我的主要问题是是什么导致了这样的错误

您在这一行中将q重新定义为整数-

int q = rand() % 1000 + 1; 

这导致了编译错误。

相关内容

最新更新