Skip to content

Commit 3d68f46

Browse files
authored
Fix compatibility with protobuf 22 (#405)
Signed-off-by: Silvio Traversaro <silvio@traversaro.it>
1 parent dcb737f commit 3d68f46

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ message(STATUS "\n\n-- ====== Finding Dependencies ======")
3838

3939
#--------------------------------------
4040
# Find Protobuf
41-
set(REQ_PROTOBUF_VER 3)
4241
ign_find_package(IgnProtobuf
43-
VERSION ${REQ_PROTOBUF_VER}
4442
REQUIRED
4543
PRETTY Protobuf)
4644

include/gz/transport/RepHandler.hh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#pragma warning(pop)
2727
#endif
2828

29-
#if GOOGLE_PROTOBUF_VERSION > 2999999
29+
#if GOOGLE_PROTOBUF_VERSION > 2999999 && GOOGLE_PROTOBUF_VERSION < 4022000
3030
#include <google/protobuf/stubs/casts.h>
3131
#endif
3232

@@ -140,7 +140,11 @@ namespace ignition
140140
return false;
141141
}
142142

143-
#if GOOGLE_PROTOBUF_VERSION > 2999999
143+
#if GOOGLE_PROTOBUF_VERSION >= 4022000
144+
auto msgReq =
145+
google::protobuf::internal::DownCast<const Req*>(&_msgReq);
146+
auto msgRep = google::protobuf::internal::DownCast<Rep*>(&_msgRep);
147+
#elif GOOGLE_PROTOBUF_VERSION > 2999999
144148
auto msgReq = google::protobuf::down_cast<const Req*>(&_msgReq);
145149
auto msgRep = google::protobuf::down_cast<Rep*>(&_msgRep);
146150
#else

include/gz/transport/SubscriptionHandler.hh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

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

31-
#if GOOGLE_PROTOBUF_VERSION >= 3000000
31+
#if GOOGLE_PROTOBUF_VERSION >= 3000000 && GOOGLE_PROTOBUF_VERSION < 4022000
3232
#include <google/protobuf/stubs/casts.h>
3333
#endif
3434

@@ -211,7 +211,9 @@ namespace ignition
211211
if (!this->UpdateThrottling())
212212
return true;
213213

214-
#if GOOGLE_PROTOBUF_VERSION >= 3000000
214+
#if GOOGLE_PROTOBUF_VERSION >= 4022000
215+
auto msgPtr = google::protobuf::internal::DownCast<const T*>(&_msg);
216+
#elif GOOGLE_PROTOBUF_VERSION >= 3000000
215217
auto msgPtr = google::protobuf::down_cast<const T*>(&_msg);
216218
#else
217219
auto msgPtr = google::protobuf::internal::down_cast<const T*>(&_msg);

0 commit comments

Comments
 (0)