Closed embeddedpenguin closed 2 years ago
"taking a reference" refers to a C++ reference type, as can be seen in the type signature.
Thus sub.recv(msg)
(removing the &
operator) should work to get rid of the warning.
"taking a reference" refers to a C++ reference type, as can be seen in the type signature. Thus
sub.recv(msg)
(removing the&
operator) should work to get rid of the warning.
Making this change causes a compilation error:
src/main.cpp:42:37: error: no matching function for call to ‘zmq::socket_t::recv(zmq::message_t&, int)’
42 | if (sub.recv(msg_recv, 0))
| ~~~~~~~~^~~~~~~~~~~~~
Also, my signature is different than the one you've referenced.
#ifdef ZMQ_CPP11
ZMQ_DEPRECATED("from 4.3.1, use recv taking a reference to message_t and recv_flags")
#endif
bool recv(message_t *msg_, int flags_ = 0)
{
int nbytes = zmq_msg_recv(msg_->handle(), _handle, flags_);
if (nbytes >= 0)
return true;
if (zmq_errno() == EAGAIN)
return false;
throw error_t();
}
I'm compiling with -std=gnu++11
. My zmq version is 4.6.0. Even when compiling with -std=gnu++17
, the result is the same.
Ok I see what's happening. Fixed by adding this:
if (sub.recv(msg_recv, zmq::recv_flags(0)))
{}
Warning:
Snippet:
Can't really get around this warning, despite using the function with a flags argument like the warning wants.