我试着编译简单的代码
#include <atomic>
int bar = 0;
void foo(std::atomic<int>&flag)
{ bar = flag; }
使用 clang++ 3.2(从 llvm.org 下载为 llvm 3.2;在 mac os.x 10.8.3 上失败并出现错误
/> clang++ -std=c++11 -stdlib=libc++ -O3 -march=native -c test.cc
In file included from test.cc:1:
/usr/include/c++/v1/atomic:576:17: error: first argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)
{return __c11_atomic_load(&__a_, __m);} ^ ~~~~~
/usr/include/c++/v1/atomic:580:53: note: in instantiation of member function 'std::_1::_atomic_base::load' requested here
operator _Tp() const _NOEXCEPT {return load();} ^
test.cc:5:9: note: in instantiation of member function 'std::_1::_atomic_base::operator int' requested here
bar = done;
当我改用/usr/bin/clang++(操作系统或 Xcode 附带)时,它编译得很好。在这两种情况下,libc++ 都位于/usr/lib/c++/v1。
我错过了什么?是否有另一个 libc++ 随 llvm 3.2 但我丢失了? (我在 clang3.2 树中找不到任何东西)。
最佳答案
Xcode 现在将 libc++ 捆绑在 Xcode.app 目录中。您可以通过按住 Control 键并单击 Xcode.app 并选择“显示包内容”来检查此目录。
关于c++ - clang 3.2 在 std::atomic 上失败——一个 libc++ 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16215421/