Is_lock_free not defined in std :: atomic <T> in gcc 4.7.2?
I ran into this compiler error
function std :: atomic :: is_lock_free () const: error: undefined reference to '__atomic_is_lock_free'
when compiling the code as shown below using gcc 4.7.2 on linux.
struct S { int a; int b; }; std::atomic<S> s; cout << s.is_lock_free() << endl; +4
Derek
source share1 answer
The atomic API is not complete in GCC 4.7:
- If lock instructions are not available (either through hardware or OS support), atomic operations remain as function calls that must be resolved by the library. Due to time limitations and an API that is not completed, there is no libatomic shipped with GCC 4.7. This can be easily determined by encountering unsatisfied external characters starting with
__atomic_*.
Since there is no libatomic shipped with GCC 4.7, you need to use another compiler that actually supports the functions you want, or provide the missing functions ( sample implementation ).
+10
Zeta
source share