Skip to content

Commit fd2d093

Browse files
authored
replace deprecated CreateMessage with Create (#248)
1 parent b082b35 commit fd2d093

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: src/viam/sdk/services/private/mlmodel_client.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121

2222
#include <viam/sdk/common/exception.hpp>
2323

24+
// As of proto version 27 (full version number 5.27) Arena::CreateMessage is deprecated in favor of
25+
// Arena::Create. We use this macro to accomodate earlier supported versions of proto where
26+
// CreateMessage was not yet deprecated, or where it was present but with different,
27+
// non-substitutable semantics
28+
#if GOOGLE_PROTOBUF_VERSION >= 5027000
29+
#define VIAM_SDK_PB_CREATE_MESSAGE Create
30+
#else
31+
#define VIAM_SDK_PB_CREATE_MESSAGE CreateMessage
32+
#endif
33+
2434
namespace viam {
2535
namespace sdk {
2636
namespace impl {
@@ -36,11 +46,11 @@ std::shared_ptr<MLModelService::named_tensor_views> MLModelServiceClient::infer(
3646
namespace mlpb = ::viam::service::mlmodel::v1;
3747

3848
auto arena = std::make_unique<pb::Arena>();
39-
auto* const req = pb::Arena::CreateMessage<mlpb::InferRequest>(arena.get());
49+
auto* const req = pb::Arena::VIAM_SDK_PB_CREATE_MESSAGE<mlpb::InferRequest>(arena.get());
4050

4151
req->set_name(this->name());
4252
*req->mutable_extra() = map_to_struct(extra);
43-
auto* const resp = pb::Arena::CreateMessage<mlpb::InferResponse>(arena.get());
53+
auto* const resp = pb::Arena::VIAM_SDK_PB_CREATE_MESSAGE<mlpb::InferResponse>(arena.get());
4454
ClientContext ctx;
4555

4656
struct arena_and_views {

0 commit comments

Comments
 (0)