0

When i use FMDB test demo in xcode4.2, everything is good. But when I run the demo in xcode 3.2.6, it gives the error:"unknown property attribute 'atomic'"

        __unsafe_unretained id _delegate;

    NSUInteger          _maximumNumberOfDatabasesToCreate;
}

@property (atomic, retain) NSString *path;
@property (atomic, assign) id delegate;
@property (atomic, assign) NSUInteger maximumNumberOfDatabasesToCreate;

How can I fix this error ?

Jordan Carroll
  • 696
  • 2
  • 11
  • 29

3 Answers3

1

As far as I remember "atomic" attribute supported only by clang. When using gcc every property not declared as "nonatomic" is "atomic" by default.

Semyon Novikov
  • 261
  • 4
  • 10
  • Hi ,I have not seen this property as keywords also. But why this demo run well in my xcode4.2 ? My ios sdk is 5.0. – TangPengChuan Jan 23 '13 at 15:15
  • Xcode 4.x using clang compiler, while 3.x primary using gcc compiler. That simple. You can try to change compiler in Project Settings. Unfortunately I have no Xcode 3.x installed, so can't provide screenshot for you, sorry. You can try to remove all occurrences of "atomic" from code and compile project with Xcode 3.x – Semyon Novikov Jan 23 '13 at 15:18
0

atomic and __unsafe_unretained were introduced with LLVM 3.0. If you are using Xcode 3.2.6, you are using an older version of the compiler that does not support those keywords.

You can safely remove the atomic keyword, since a property is atomic by default; and also remove __unsafe_unretained, since approximately it is equivalent to assign in a property declaration.

sergio
  • 68,819
  • 11
  • 102
  • 123
0

You can use Clang's preprocessor macros to determine whether atomic is available in your compiler. If the atomic keyword is not supported, it should be safe to omit it, since atomic is the implicit behavior anyway.

#if __has_feature(objc_atomic)
@property (atomic, retain) NSString *path;
@property (atomic, assign) id delegate;
@property (atomic, assign) NSUInteger maximumNumberOfDatabasesToCreate;
#else
@property (retain) NSString *path;
@property (assign) id delegate;
@property (assign) NSUInteger maximumNumberOfDatabasesToCreate;
#endif
Raptor007
  • 366
  • 3
  • 10