OSAtomicIncrement32 is missing deprecation warning

i can not see a deprecation warning for OSAtomicIncrement32 during compilation despite of this in the header:

@available (iOS, deprecated: 10.0, message: "Use atomic_fetch_add_explicit(memory_order_relaxed) from <stdatomic.h> instead")

is this a bug?

What’s your deployment target? Anything less than 10 wont show the warning.

1 Like

it is 13...

You're right, I can reproduce this in my iOS 13 projects as well. You should report it as a bug.

i was hoping it is somehow "undeprecated" as i don't see an easy way to use atomic_fetch_add_explicit from swift without jumping through hoops.

@scanon or @lorentey Do you know the status of these APIs? It seems possible the deprecation was disabled in a way that isn't visible to us.

The most likely explanation is that the OSAtomic.h header has been included with OSATOMIC_USE_INLINED=1 defined, which causes the deprecation warning to be suppressed and expands the legacy OSAtomic operations with their <stdatomic.h> replacements inline. Note that this is intended as a transition assistant; C users should still plan to migrate to the <stdatomic.h> bindings, and Swift users should plan to migrate to whatever Swift settles on for atomics.

Quoting the OSAtomic header:

 * These are deprecated legacy interfaces for atomic operations.
 * The C11 interfaces in <stdatomic.h> resp. C++11 interfaces in <atomic>
 * should be used instead.
 *
 * Define OSATOMIC_USE_INLINED=1 to get inline implementations of these
 * interfaces in terms of the <stdatomic.h> resp. <atomic> primitives.
 * This is intended as a transition convenience, direct use of those primitives
 * is preferred.
3 Likes