anon anon - 9 months ago 102
C++ Question

How do I use gcc builtin __sync_bool_compare_and_swap in g++ on MacOSX?

I have some code that uses:


it compiles fine on Linux.

But when I try to compile it on MacOSX in g++, I get:

error: ‘__sync_bool_compare_and_swap’ was not declared in this scope

How do I fix this? (This is Mac OSX 10.5.8, so it's intel .. .and should have this instruction).


Answer Source

If you can't find it, you can use OSCompareAndSwap() on Mac.

But it would be nice to have cross-platform code, wouldn't it.