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.
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:
- 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_*
.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With