I have two projects open in Xcode 6.4. Both use the follow declaration:
- (void)startService
{
__weak typeof(self) weakSelf = self;
[self.messageOperationQueue addOperationWithBlock:^{
NSDictionary *storedMessages = [mySettings get:kStorageName withDefault:@{} storageType:kMySettingsStorageTypeDiskMapped];
[weakSelf.messages addEntriesFromDictionary:storedMessages];
}];
}
However, in one project there are no errors, and in the other project I get a compiler error:
Expected ';' at end of declaration
It wants me to put a semi-colon after __weak typeof(self). I have suspicion that I'm just doing something really dumb, but I'm having trouble figuring out what. Also, I know I could replace the typeof(self)
with myClass *
.
Use __typeof
instead of typeof
.
This is because both __typeof
and typeof
are extensions to C, but typeof
is only enabled in Clang when the language is a GNUXX
variant of C, but not for CXX
.
I had a similar error. @Leo Natan is right and if you want, you can change the C dialect to GNU like this:
In the Project Navigator go to Project -> Target -> Build Settings
There look for C Language Dialect and change it from c11 or c99 to GNU99 and it will solve the problem. Now you can use typeof()
I hope it helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With