[问题] 执行绪退出

楼主: WashFreeID (免洗)   2014-04-19 10:51:47
开发平台(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):
自己基础很差
不太会要怎样让它编译过
感谢各位大大
作者: asilzheng (asil)   2014-04-19 11:17:00
tfn2 的pthread_clean_pop,是 cleanup另外还要 include <errno.h><unistd.h><string.h>
作者: ah7675 (阿毛)   2014-04-19 16:58:00
现在errno都已经用TLS在存了 没有覆蓋问题
楼主: WashFreeID (免洗)   2014-04-19 23:26:00
谢谢楼上 我会再去了解一下

Links booklink

Contact Us: admin [ a t ] ucptt.com