Skip to content

Commit 0bd6e40

Browse files
markchandlera-maurice
authored andcommitted
Firebase cpp: Fixed older visual studio builds due to small string change and using sizeof anonymous struct in a union
PiperOrigin-RevId: 273538646
1 parent 910c277 commit 0bd6e40

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

app/src/include/firebase/variant.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,14 @@ class Variant {
10661066

10671067
// Current type contained in this Variant.
10681068
Type type_;
1069+
1070+
// Older versions of visual studio cant have this inline in the union and do
1071+
// sizeof for small string
1072+
typedef struct {
1073+
const uint8_t* ptr;
1074+
size_t size;
1075+
} BlobValue;
1076+
10691077
// Union of plain old data (scalars or pointers).
10701078
union Value {
10711079
int64_t int64_value;
@@ -1075,11 +1083,8 @@ class Variant {
10751083
std::string* mutable_string_value;
10761084
std::vector<Variant>* vector_value;
10771085
std::map<Variant, Variant>* map_value;
1078-
struct {
1079-
const uint8_t* ptr;
1080-
size_t size;
1081-
} blob_value;
1082-
char small_string[sizeof(blob_value)];
1086+
BlobValue blob_value;
1087+
char small_string[sizeof(BlobValue)];
10831088
} value_;
10841089

10851090
static const size_t kMaxSmallStringSize = sizeof(Value::small_string);

0 commit comments

Comments
 (0)