Skip to content

Commit 1d1dd64

Browse files
authored
Use C99-compatible __typeof__ instead of typeof (#1985)
`typeof` is only defined if you compile with GNU extensions, while `__typeof__` is always available. This is the Firestore equivalent of #1982. Note that Firestore won't yet build in this mode because among other things the Objective-C gRPC still uses `typeof`. Once we eliminate that dependency this might become possible.
1 parent 420dfc2 commit 1d1dd64

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Firestore/Source/Core/FSTFirestoreClient.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ - (instancetype)initWithDatabaseInfo:(const DatabaseInfo &)databaseInfo
129129

130130
auto userPromise = std::make_shared<std::promise<User>>();
131131

132-
__weak typeof(self) weakSelf = self;
132+
__weak __typeof__(self) weakSelf = self;
133133
auto credentialChangeListener = [initialized = false, userPromise, weakSelf,
134134
workerDispatchQueue](User user) mutable {
135-
typeof(self) strongSelf = weakSelf;
135+
__typeof__(self) strongSelf = weakSelf;
136136
if (!strongSelf) return;
137137

138138
if (!initialized) {

Firestore/Source/Util/FSTClasses.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ NS_ASSUME_NONNULL_BEGIN
2828
userInfo:nil];
2929

3030
// Declare a weak pointer to the given variable
31-
#define FSTWeakify(var) __weak typeof(var) fstWeakPointerTo##var = var;
31+
#define FSTWeakify(var) __weak __typeof__(var) fstWeakPointerTo##var = var;
3232

3333
// Declare a strong pointer to a variable that's been FSTWeakified. This creates a shadow of the
3434
// original.
3535
#define FSTStrongify(var) \
3636
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wshadow\"") \
37-
__strong typeof(var) var = fstWeakPointerTo##var; \
37+
__strong __typeof__(var) var = fstWeakPointerTo##var; \
3838
_Pragma("clang diagnostic pop")
3939

4040
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)