加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – OS X clang -pthread

发布时间:2020-12-16 07:53:53 所属栏目:百科 来源:网络整理
导读:在OS X中使用带有clang的pthread库有什么编译器/链接器要求. 使用GCC我知道使用-pthread设置适当的编译器/链接器选项,但我不确定OS X与clang. air:~ jose$clang++ -c test.cpp -pthreadair:~ jose$clang++ -o test -pthread test.o clang: warning: argument
在OS X中使用带有clang的pthread库有什么编译器/链接器要求.

使用GCC我知道使用-pthread设置适当的编译器/链接器选项,但我不确定OS X与clang.

air:~ jose$clang++ -c test.cpp -pthread
air:~ jose$clang++ -o test -pthread test.o 
clang: warning: argument unused during compilation: '-pthread'

air:~ jose$g++ -c test.cpp -pthread
air:~ jose$g++ -o test -pthread test.o

解决方法

clang在编译时需要-pthread,但在链接时不需要.pthread.这很烦人,但观察到的行为:
$clang -c x.cpp
$clang -pthread -c x.cpp
$clang -o x x.o
$clang -pthread -o x x.o
clang: warning: argument unused during compilation: '-pthread'
$

$clang --version
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
$

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读