Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile with protobuf 22-25. #2576

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/brpc/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@

// 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
wasphin marked this conversation as resolved.
Show resolved Hide resolved
#define private public
#include <google/protobuf/io/coded_stream.h>
const int PB_TOTAL_BYETS_LIMITS_RAW =
google::protobuf::io::CodedInputStream::kDefaultTotalBytesLimit;
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>
Expand Down
2 changes: 1 addition & 1 deletion src/json2pb/json_to_pb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/json2pb/pb_to_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading