您的位置:首页 > 编程语言 > Go语言

《Go语言编程》[4.4 并发通信]代码thread.c和thread.go错误

2015-04-30 10:27 302 查看
thread.c程序pthread_create函数第三个参数为线程函数的起始地址,文中并无add函数,源代码如下:





thread.c编译时会报未声明错误:





根据语境推测应该是count,替换如下:





重新编译,gcc编译时在最后加参数-lpthread,否则编译报对

pthread_create和pthread_join未定义的引用如下:





应当是行末最后加入-lpthread编译,正确编译命令:

gcc -lpthread thread.c -o main

thread.go程序无z变量,应当是counter:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐