C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – OS X clang -pthread大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在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
$

大佬总结

以上是大佬教程为你收集整理的c – OS X clang -pthread全部内容,希望文章能够帮你解决c – OS X clang -pthread所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: