"__weak typeof(self) weakSelf = self;" expected ; at end of declaration
objective-c
Solution
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`.
Problem
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 *`.