简体   繁体   English

is_lock_free未在std :: atomic中定义 <T> 在gcc 4.7.2?

[英]is_lock_free not defined in std::atomic<T> in gcc 4.7.2?

I encounter this compiler error 我遇到这个编译错误

function std::atomic::is_lock_free() const: error: undefined reference 
to '__atomic_is_lock_free'

when compiling code like below using gcc 4.7.2 on linux. 在Linux上使用gcc 4.7.2编译代码如下所示。

struct S {
  int a;
  int b;
};


  std::atomic<S> s;
  cout << s.is_lock_free() << endl;

Atomic API isn't complete in GCC 4.7: GCC 4.7中的Atomic API不完整:

  • When lock free instructions are not available (either through hardware or OS support) atomic operations are left as function calls to be resolved by a library. 当无锁指令不可用时(通过硬件或OS支持),原子操作留作函数调用以由库解析。 Due to time constraints and an API which is not finalized, there is no libatomic supplied with GCC 4.7. 由于时间限制和API尚未最终确定,因此没有GCC 4.7提供的libatomic。 This is easily determined by encountering unsatisfied external symbols beginning with __atomic_* . 这很容易通过遇到以__atomic_*开头的__atomic_*满足的外部符号来确定。

Since there is no libatomic shipped with GCC 4.7 you need to use another compiler which actually supports the features you want or provide the missing features ( sample implementation ). 由于GCC 4.7附带没有libatomic ,因此您需要使用另一个实际支持您所需功能的编译器或提供缺少的功能( 示例实现 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM