15

我正在从 g++ 切换到 clang

但是,在 g++ 中,我有 -pthread 标志,clang 似乎无法识别。

clang 中的等价物是什么?

编辑:我的 clang 版本是 2010 年 3 月 5 日从 svn 中提取的。

4

2 回答 2

35

clang-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
$
于 2013-10-15T13:39:34.143 回答
14

Clang支持 -pthread. 可能在最新版本中,因此请更新并重试。

于 2010-03-06T03:16:49.527 回答