我正在尝试为餐饮哲学家的问题创建多个线程并将不同的值传递给每个线程。但我收到此错误:
warning: cast to pointer from integer of different size
这是我的代码:
pthread_mutex_t mutex;
pthread_cond_t cond_var;
pthread_t philo[NUM];
int main( void )
{
int i;
pthread_mutex_init (&mutex, NULL);
pthread_cond_init (&cond_var, NULL);
//Create a thread for each philosopher
for (i = 0; i < NUM; i++)
pthread_create (&philo[i], NULL,(void *)philosopher,(void *)i); // <-- error here
//Wait for the threads to exit
for (i = 0; i < NUM; i++)
pthread_join (philo[i], NULL);
return 0;
}
void *philosopher (void *num)
{
//some code
}