is_lock_free未在std :: atomic< T>中定义在gcc 4.7.2? [英] is_lock_free not defined in std::atomic<T> in gcc 4.7.2?

查看:876
本文介绍了is_lock_free未在std :: atomic< T>中定义在gcc 4.7.2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到此编译器错误


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

struct S {
  int a;
  int b;
};


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


推荐答案

GCC 4.7中没有完成原子API:



  • 当无锁指令不可用(通过硬件或操作系统支持)时,原子操作留作函数调用由库解析。 由于时间限制和未完成的API,GCC 4.7没有提供libatomic。这很容易通过遇到以 __ atomic _ * 开头的未满足的外部符号来确定。

  • 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. Due to time constraints and an API which is not finalized, there is no libatomic supplied with GCC 4.7. This is easily determined by encountering unsatisfied external symbols beginning with __atomic_*.

由于GCC 4.7中没有 libatomic ,因此您需要使用另一个实际支持所需功能的编译器,缺少功能(示例实现 )。

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).

这篇关于is_lock_free未在std :: atomic&lt; T&gt;中定义在gcc 4.7.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆