Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 3: atomic_compare_exchange_strong

Tags:

atomic

swift

Getting following warning in Xcode 8 / Swift 3:

warning: 'OSAtomicCompareAndSwap32Barrier' was deprecated in OS X 10.12:
         Use atomic_compare_exchange_strong() from <stdatomic.h> instead

Attempt to use function atomic_compare_exchange_strong in Swift code leads compiler error:

error: use of unresolved identifier 'atomic_compare_exchange_strong'

Importing Darwin or CoreFoundation modules does not solve problem.

What module should I import in order to get symbol for atomic_compare_exchange_strong?

Thank you!

like image 503
Vlad Avatar asked Sep 06 '16 19:09

Vlad


1 Answers

I know this is a question for Swift 3, but in case anyone stumbles across this, now there is a Swift Atomics package (introduced in Oct 2020) which can be used for this functionality.

like image 170
typesanitizer Avatar answered Oct 22 '22 12:10

typesanitizer