Skip to content

Commit a819813

Browse files
committed
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.
1 parent ce806ee commit a819813

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

zmq.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,15 @@ namespace zmq
492492
if (rc == -1 && zmq_errno() == ETERM)
493493
break;
494494
assert (rc != -1);
495+
#if ZMQ_VERSION_MAJOR >= 4
495496
const char* data = static_cast<const char*>(zmq_msg_data(&eventMsg));
496497
zmq_event_t msgEvent;
497498
msgEvent.event = *(uint16_t*)data; data += sizeof(uint16_t);
498499
msgEvent.value = *(int32_t*)data;
499500
zmq_event_t* event = &msgEvent;
501+
#else
502+
zmq_event_t* event = static_cast<zmq_event_t*>(zmq_msg_data(&eventMsg));
503+
#endif
500504

501505
#ifdef ZMQ_NEW_MONITOR_EVENT_LAYOUT
502506
zmq_msg_t addrMsg;

0 commit comments

Comments
 (0)