Work around GOOGLE_* changes in protobuf >= 22.0

According to the protobuf migration guide as of June 2023 [0], protobuf
22.0 (aka 4.22.0) took a dependency on something called "abseil" and as
a result the "stubs" have been removed. This apparently caused all the
uses of GOOGLE_* identifiers in protoc-c to fail when building against
newer versions of protobuf.

This commit introduces compatibility definitions when building against
protobuf >= 4.22.0 so that protobuf-c can build against older and newer
versions of protobuf.

[0] https://web.archive.org/web/20230611151200/https://protobuf.dev/support/migration/#abseil
This commit is contained in:
Robert Edmonds 2023-07-02 19:42:19 -04:00
parent 7b90330bff
commit 8d334a7204

View File

@ -178,6 +178,16 @@ inline int FieldSyntax(const FieldDescriptor* field) {
#endif #endif
} }
// Work around changes in protobuf >= 22.x without breaking compilation against
// older protobuf versions.
#if GOOGLE_PROTOBUF_VERSION >= 4022000
# define GOOGLE_ARRAYSIZE ABSL_ARRAYSIZE
# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
# define GOOGLE_DCHECK_GE ABSL_DCHECK_GE
# define GOOGLE_LOG ABSL_LOG
#endif
} // namespace c } // namespace c
} // namespace compiler } // namespace compiler
} // namespace protobuf } // namespace protobuf