ports/devel/protobuf-c/patches/patch-protoc-c_c_helpers_h

43 lines
1.3 KiB
Text
Raw Normal View History

2023-09-17 04:05:06 +00:00
https://github.com/protobuf-c/protobuf-c/pull/673
Index: protoc-c/c_helpers.h
--- protoc-c/c_helpers.h.orig
+++ protoc-c/c_helpers.h
@@ -70,6 +70,10 @@
#include <protobuf-c/protobuf-c.pb.h>
#include <google/protobuf/io/printer.h>
+#if GOOGLE_PROTOBUF_VERSION >= 4023000
+# include <google/protobuf/descriptor_legacy.h>
+#endif
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -172,11 +176,25 @@ int compare_name_indices_by_name(const void*, const vo
// This wrapper is needed to be able to compile against protobuf2.
inline int FieldSyntax(const FieldDescriptor* field) {
#ifdef HAVE_PROTO3
+# if GOOGLE_PROTOBUF_VERSION >= 4023000
+ return FileDescriptorLegacy(field->file()).syntax() == FileDescriptorLegacy::SYNTAX_PROTO3 ? 3 : 2;
+# else
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ? 3 : 2;
+# endif
#else
return 2;
#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 compiler