Skip to content

Commit

Permalink
Fix compatibility with protobuf 22 (#405)
Browse files Browse the repository at this point in the history
Signed-off-by: Silvio Traversaro <[email protected]>
  • Loading branch information
traversaro authored Jun 10, 2023
1 parent dcb737f commit 3d68f46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ message(STATUS "\n\n-- ====== Finding Dependencies ======")

#--------------------------------------
# Find Protobuf
set(REQ_PROTOBUF_VER 3)
ign_find_package(IgnProtobuf
VERSION ${REQ_PROTOBUF_VER}
REQUIRED
PRETTY Protobuf)

Expand Down
8 changes: 6 additions & 2 deletions include/gz/transport/RepHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#pragma warning(pop)
#endif

#if GOOGLE_PROTOBUF_VERSION > 2999999
#if GOOGLE_PROTOBUF_VERSION > 2999999 && GOOGLE_PROTOBUF_VERSION < 4022000
#include <google/protobuf/stubs/casts.h>
#endif

Expand Down Expand Up @@ -140,7 +140,11 @@ namespace ignition
return false;
}

#if GOOGLE_PROTOBUF_VERSION > 2999999
#if GOOGLE_PROTOBUF_VERSION >= 4022000
auto msgReq =
google::protobuf::internal::DownCast<const Req*>(&_msgReq);
auto msgRep = google::protobuf::internal::DownCast<Rep*>(&_msgRep);
#elif GOOGLE_PROTOBUF_VERSION > 2999999
auto msgReq = google::protobuf::down_cast<const Req*>(&_msgReq);
auto msgRep = google::protobuf::down_cast<Rep*>(&_msgRep);
#else
Expand Down
6 changes: 4 additions & 2 deletions include/gz/transport/SubscriptionHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <google/protobuf/stubs/common.h>

#if GOOGLE_PROTOBUF_VERSION >= 3000000
#if GOOGLE_PROTOBUF_VERSION >= 3000000 && GOOGLE_PROTOBUF_VERSION < 4022000
#include <google/protobuf/stubs/casts.h>
#endif

Expand Down Expand Up @@ -211,7 +211,9 @@ namespace ignition
if (!this->UpdateThrottling())
return true;

#if GOOGLE_PROTOBUF_VERSION >= 3000000
#if GOOGLE_PROTOBUF_VERSION >= 4022000
auto msgPtr = google::protobuf::internal::DownCast<const T*>(&_msg);
#elif GOOGLE_PROTOBUF_VERSION >= 3000000
auto msgPtr = google::protobuf::down_cast<const T*>(&_msg);
#else
auto msgPtr = google::protobuf::internal::down_cast<const T*>(&_msg);
Expand Down

0 comments on commit 3d68f46

Please sign in to comment.