I need (just for debugging purposes) to count something in a thread safe way.
This works, but is deprecated:
SInt32 counter;
- (IBAction)doSomething:sender
{
counter = 0;
some loop
{
IncrementAtomic( &counter ); // 'IncrementAtomic' is
deprecated: first deprecated in macOS 10.8
....
}
fprintf(stderr, "counter %lld\n", counter); // works ok
}
The deprecation message did not say what to use instead. So I tried
OSIncrementAtomic.
Now I get: "Implicit declaration of function 'OSIncrementAtomic' is invalid in
C99" and the linker fails, because it does not find it.
#import <libkern/OSAtomic.h> does not help at all.
When I add the Kernel.framework these errors disappear (good), but are only
replaced by: “ld: framework not found Kernel” (not so good).
So what is the proper way to count something atomicly and undeprecatedly?
Gerriet.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]