Skip to content

Commit de68c2b

Browse files
authored
Fix "Undefined symbols" linker error when DocumentChange::npos was used (#474)
1 parent d682fd9 commit de68c2b

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

firestore/integration_test/src/integration_test.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,14 @@ TEST_F(FirebaseFirestoreBasicTest, TestQuery) {
651651
"int", firebase::firestore::FieldValue::Integer(101))))));
652652
}
653653

654+
TEST_F(FirebaseFirestoreBasicTest, TestDocumentChangeNpos) {
655+
// This test may seem pointless, but it exists to avoid the long-standing
656+
// latent bug that `npos` was not defined on non-Android platforms and
657+
// would therefore fail to link if used.
658+
EXPECT_EQ(firebase::firestore::DocumentChange::npos,
659+
static_cast<std::size_t>(-1));
660+
}
661+
654662
TEST_F(FirebaseFirestoreBasicTest,
655663
TestInvalidatingReferencesWhenDeletingFirestore) {
656664
delete firestore_;

firestore/integration_test_internal/src/integration_test.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,14 @@ TEST_F(FirebaseFirestoreBasicTest, TestQuery) {
651651
"int", firebase::firestore::FieldValue::Integer(101))))));
652652
}
653653

654+
TEST_F(FirebaseFirestoreBasicTest, TestDocumentChangeNpos) {
655+
// This test may seem pointless, but it exists to avoid the long-standing
656+
// latent bug that `npos` was not defined on non-Android platforms and
657+
// would therefore fail to link if used.
658+
EXPECT_EQ(firebase::firestore::DocumentChange::npos,
659+
static_cast<std::size_t>(-1));
660+
}
661+
654662
TEST_F(FirebaseFirestoreBasicTest,
655663
TestInvalidatingReferencesWhenDeletingFirestore) {
656664
delete firestore_;

firestore/src/common/document_change.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ using Type = DocumentChange::Type;
2323
// Older NDK (r16b) fails to define this properly. Fix this when support for
2424
// the older NDK is removed.
2525
const std::size_t DocumentChange::npos = static_cast<std::size_t>(-1);
26+
#else
27+
constexpr std::size_t DocumentChange::npos;
2628
#endif // defined(ANDROID)
2729

2830
DocumentChange::DocumentChange() {}

release_build_files/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ code.
567567

568568
## Release Notes
569569

570+
### 8.1.0
571+
- Changes
572+
- Firestore: Fixed a linker error when `DocumentChange::npos` was used.
573+
([#474](https://github.com/firebase/firebase-cpp-sdk/pull/474)).
574+
570575
### 8.0.0
571576
- Changes
572577
- Analytics: Removed `SetCurrentScreen()` following its removal from iOS SDK

0 commit comments

Comments
 (0)