diff --git a/src/brpc/protocol.cpp b/src/brpc/protocol.cpp index 5f39939d1a..e0468c22ff 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 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 +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 #include diff --git a/src/json2pb/json_to_pb.cpp b/src/json2pb/json_to_pb.cpp index 2652d6d487..60ba4fdfc9 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 a299e42462..b0066dc6dc 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)