21

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!

Vlad
  • 6,402
  • 1
  • 60
  • 74
  • 6
    I would have said `import Darwin.C.stdatomic` - or even `#include ` in a bridging header, but it doesn't bring `atomic_compare_exchange_strong` when I test it. And I see https://openradar.appspot.com/27161329 so maybe it's just not there yet. – Eric Aya Sep 06 '16 at 20:39
  • 1
    So does this mean APPLE is forcing us into the standard lib now? Not good. – Ray Garner Apr 16 '19 at 06:31

1 Answers1

2

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.

typesanitizer
  • 2,505
  • 1
  • 20
  • 44