This is an automated email from the ASF dual-hosted git repository. wwbmmm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push: new e1447025 Fix compile with protobuf 22-25. (#2576) e1447025 is described below commit e1447025aeb9def25b5eb18073b3424635fc2808 Author: Ketor <d.ke...@gmail.com> AuthorDate: Thu Mar 21 13:42:01 2024 +0800 Fix compile with protobuf 22-25. (#2576) Signed-off-by: Ketor <d.ke...@gmail.com> --- src/brpc/protocol.cpp | 8 ++++++++ src/json2pb/json_to_pb.cpp | 2 +- src/json2pb/pb_to_json.cpp | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/brpc/protocol.cpp b/src/brpc/protocol.cpp index 5f39939d..e0468c22 100644 --- a/src/brpc/protocol.cpp +++ b/src/brpc/protocol.cpp @@ -18,6 +18,8 @@ // Since kDefaultTotalBytesLimit is private, we need some hacks to get the limit. // Works for pb 2.4, 2.6, 3.0 +#include "google/protobuf/stubs/common.h" +#if GOOGLE_PROTOBUF_VERSION < 4022000 #define private public #include <google/protobuf/io/coded_stream.h> const int PB_TOTAL_BYETS_LIMITS_RAW = @@ -25,6 +27,12 @@ const int PB_TOTAL_BYETS_LIMITS_RAW = const uint64_t PB_TOTAL_BYETS_LIMITS = PB_TOTAL_BYETS_LIMITS_RAW < 0 ? (uint64_t)-1LL : PB_TOTAL_BYETS_LIMITS_RAW; #undef private +#else +#include <google/protobuf/io/coded_stream.h> +const int PB_TOTAL_BYETS_LIMITS_RAW = INT_MAX; +const uint64_t PB_TOTAL_BYETS_LIMITS = + PB_TOTAL_BYETS_LIMITS_RAW < 0 ? (uint64_t)-1LL : PB_TOTAL_BYETS_LIMITS_RAW; +#endif #include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/text_format.h> diff --git a/src/json2pb/json_to_pb.cpp b/src/json2pb/json_to_pb.cpp index 2652d6d4..60ba4fdf 100644 --- a/src/json2pb/json_to_pb.cpp +++ b/src/json2pb/json_to_pb.cpp @@ -534,7 +534,7 @@ bool JsonValueToProtoMessage(const BUTIL_RAPIDJSON_NAMESPACE::Value& json_value, for (int i = 0; i < descriptor->extension_range_count(); ++i) { const google::protobuf::Descriptor::ExtensionRange* ext_range = descriptor->extension_range(i); -#if GOOGLE_PROTOBUF_VERSION < 4022000 +#if GOOGLE_PROTOBUF_VERSION < 4025000 for (int tag_number = ext_range->start; tag_number < ext_range->end; ++tag_number) #else for (int tag_number = ext_range->start_number(); tag_number < ext_range->end_number(); ++tag_number) diff --git a/src/json2pb/pb_to_json.cpp b/src/json2pb/pb_to_json.cpp index a299e424..b0066dc6 100644 --- a/src/json2pb/pb_to_json.cpp +++ b/src/json2pb/pb_to_json.cpp @@ -75,7 +75,7 @@ bool PbToJsonConverter::Convert(const google::protobuf::Message& message, Handle for (int i = 0; i < ext_range_count; ++i) { const google::protobuf::Descriptor::ExtensionRange* ext_range = descriptor->extension_range(i); -#if GOOGLE_PROTOBUF_VERSION < 4022000 +#if GOOGLE_PROTOBUF_VERSION < 4025000 for (int tag_number = ext_range->start; tag_number < ext_range->end; ++tag_number) #else for (int tag_number = ext_range->start_number(); tag_number < ext_range->end_number(); ++tag_number) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org