Skip to content

Commit 5999e5a

Browse files
authored
Problem: Macros not defined in older versions (#386)
* Problem: Macros not defined in older versions Solution: Guard usage of libzmq macros * Test older version of libzmq with C++11 or later * Use a slightly newer libzmq version
1 parent 324b11f commit 5999e5a

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ matrix:
4949
# GCC default, draft disabled, default libzmq (defined in ci_build.sh)
5050
- os: linux
5151

52-
# GCC 6, draft disabled (default), latest libzmq (default)
52+
# GCC 6, draft disabled (default), older libzmq
5353
- os: linux
5454
addons:
5555
apt:
@@ -58,7 +58,7 @@ matrix:
5858
packages:
5959
- g++-6
6060
env:
61-
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
61+
- ZMQ_VERSION=4.2.5 MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
6262

6363
# GCC 4.9, draft disabled (default), latest libzmq (default)
6464
- os: linux

tests/context.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ TEST_CASE("context - use socket after shutdown", "[context]")
6767
TEST_CASE("context set/get options", "[context]")
6868
{
6969
zmq::context_t context;
70+
#if defined(ZMQ_BLOCKY) && defined(ZMQ_IO_THREADS)
7071
context.set(zmq::ctxopt::blocky, false);
7172
context.set(zmq::ctxopt::io_threads, 5);
7273
CHECK(context.get(zmq::ctxopt::io_threads) == 5);
74+
#endif
7375

7476
CHECK_THROWS_AS(
7577
context.set(static_cast<zmq::ctxopt>(-42), 5),

zmq.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,21 +635,45 @@ inline void swap(message_t &a, message_t &b) ZMQ_NOTHROW
635635
#ifdef ZMQ_CPP11
636636
enum class ctxopt
637637
{
638+
#ifdef ZMQ_BLOCKY
638639
blocky = ZMQ_BLOCKY,
640+
#endif
641+
#ifdef ZMQ_IO_THREADS
639642
io_threads = ZMQ_IO_THREADS,
643+
#endif
644+
#ifdef ZMQ_THREAD_SCHED_POLICY
640645
thread_sched_policy = ZMQ_THREAD_SCHED_POLICY,
646+
#endif
647+
#ifdef ZMQ_THREAD_PRIORITY
641648
thread_priority = ZMQ_THREAD_PRIORITY,
649+
#endif
650+
#ifdef ZMQ_THREAD_AFFINITY_CPU_ADD
642651
thread_affinity_cpu_add = ZMQ_THREAD_AFFINITY_CPU_ADD,
652+
#endif
653+
#ifdef ZMQ_THREAD_AFFINITY_CPU_REMOVE
643654
thread_affinity_cpu_remove = ZMQ_THREAD_AFFINITY_CPU_REMOVE,
655+
#endif
656+
#ifdef ZMQ_THREAD_NAME_PREFIX
644657
thread_name_prefix = ZMQ_THREAD_NAME_PREFIX,
658+
#endif
659+
#ifdef ZMQ_MAX_MSGSZ
645660
max_msgsz = ZMQ_MAX_MSGSZ,
661+
#endif
646662
#ifdef ZMQ_ZERO_COPY_RECV
647663
zero_copy_recv = ZMQ_ZERO_COPY_RECV,
648664
#endif
665+
#ifdef ZMQ_MAX_SOCKETS
649666
max_sockets = ZMQ_MAX_SOCKETS,
667+
#endif
668+
#ifdef ZMQ_SOCKET_LIMIT
650669
socket_limit = ZMQ_SOCKET_LIMIT,
670+
#endif
671+
#ifdef ZMQ_IPV6
651672
ipv6 = ZMQ_IPV6,
673+
#endif
674+
#ifdef ZMQ_MSG_T_SIZE
652675
msg_t_size = ZMQ_MSG_T_SIZE
676+
#endif
653677
};
654678
#endif
655679

0 commit comments

Comments
 (0)