我有以下幾點:編譯警告返回用了pthread_exit()RETVAL當
void *Thrd(void *data)
{
int ret;
ret = myfunc();
pthread_exit((void *)ret);
}
int main(int argc, char *argv[])
{
int status;
pthread_create(&Thread, NULL, Thrd, &data);
pthread_join(txThread, (void **)&status);
if (status)
printf("*** thread failed with error %d\n", status);
}
它的工作原理,我能讀狀態但我發現下面的警告在編譯:
test.cpp: In function ‘void* Thrd(void*)’:
test.cpp:468:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
這是與線pthread_exit()
我根本就看不到什麼是錯:(...
你怎麼沒發現什麼是錯的。編譯器告訴你:「從不同大小的整數轉換爲指針」。什麼是很難理解? –