0
编译时,当我尝试编译此我得到一个错误:在pthread_create - 错误在C
warning: passing argument 1 of
pthread_create
makes pointer from integer without a cast.
请如果有人可以帮助我..
int Traveler(int id, int numBags)
{
int i;
int err;
err = pthread_create(id, NULL, Traveler, NULL);
if(err!=0)
{
return -1;
}
else
{
}
}
+1,但在'id'前加'&'不是正确的做法 - 第一个参数需要是指向“pthread_t”的指针,而不是指向“int”的指针。编译器可能会接受它(如果'pthread_t'恰好是'int'的类型定义),但通常不会。 – 2012-04-24 16:58:20
好的。已经更新了我的答案。好吧,我想这会在一行中产生4个错误... :-) – smocking 2012-04-24 17:15:59