Fixes backward compatibility with zmq 3.x

The code added in 'Fixed misaligned structure cast' implicitly assumes zmq 4.x, since it relies on new fields in zmq_event_t structure. This commit re-introduces the previous code if zmq < 4.x is detected.
This commit is contained in:
zbierak 2014-08-08 08:09:32 +00:00
parent ce806eec82
commit a819813095

View File

@ -492,11 +492,15 @@ namespace zmq
if (rc == -1 && zmq_errno() == ETERM)
break;
assert (rc != -1);
#if ZMQ_VERSION_MAJOR >= 4
const char* data = static_cast<const char*>(zmq_msg_data(&eventMsg));
zmq_event_t msgEvent;
msgEvent.event = *(uint16_t*)data; data += sizeof(uint16_t);
msgEvent.value = *(int32_t*)data;
zmq_event_t* event = &msgEvent;
#else
zmq_event_t* event = static_cast<zmq_event_t*>(zmq_msg_data(&eventMsg));
#endif
#ifdef ZMQ_NEW_MONITOR_EVENT_LAYOUT
zmq_msg_t addrMsg;