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