開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
linux gcc
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
王者歸來linux C書裡面的範例 15-7
(這本真的錯誤很多)
雖然書上寫 用-lpthread
但都沒辦法過 全部改用-pthread
餵入的資料(Input):
預期的正確結果(Expected Output):
the second thread
No . 2 clean-up procdure
.....
錯誤結果(Wrong Output):
cleanup.c:43:1: error: expected ‘while’ before ‘void’
void *tfn3(void *arg)
^
cleanup.c:84:36: error: ‘tfn3’ undeclared (first use in this function)
err = pthread_create(&tid3, NULL, tfn3, NULL);
cleanup.c:84:36: note: each undeclared identifier is reported only once for each function it appears in
cleanup.c:86:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
printf("cant create thread %s\n", strerror(err));
^
cleanup.c: In function ‘tfn2’:
cleanup.c:96:1: error: expected declaration or statement at end of input
}
^
cleanup.c:96:1: error: expected declaration or statement at end of input
程式碼(Code):(請善用置底文網頁, 記得排版)
https://github.com/hsuanchenli/C/blob/master/cleanup.c
補充說明(Supplement):
自己基礎很差
不太會要怎樣讓它編譯過
感謝各位大大