Skip to content

Commit

Permalink
Problem: Macros not defined in older versions (#386)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gummif committed Feb 21, 2020
1 parent 324b11f commit 5999e5a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ matrix:
# GCC default, draft disabled, default libzmq (defined in ci_build.sh)
- os: linux

# GCC 6, draft disabled (default), latest libzmq (default)
# GCC 6, draft disabled (default), older libzmq
- os: linux
addons:
apt:
Expand All @@ -58,7 +58,7 @@ matrix:
packages:
- g++-6
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
- ZMQ_VERSION=4.2.5 MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"

# GCC 4.9, draft disabled (default), latest libzmq (default)
- os: linux
Expand Down
2 changes: 2 additions & 0 deletions tests/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ TEST_CASE("context - use socket after shutdown", "[context]")
TEST_CASE("context set/get options", "[context]")
{
zmq::context_t context;
#if defined(ZMQ_BLOCKY) && defined(ZMQ_IO_THREADS)
context.set(zmq::ctxopt::blocky, false);
context.set(zmq::ctxopt::io_threads, 5);
CHECK(context.get(zmq::ctxopt::io_threads) == 5);
#endif

CHECK_THROWS_AS(
context.set(static_cast<zmq::ctxopt>(-42), 5),
Expand Down
24 changes: 24 additions & 0 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,21 +635,45 @@ inline void swap(message_t &a, message_t &b) ZMQ_NOTHROW
#ifdef ZMQ_CPP11
enum class ctxopt
{
#ifdef ZMQ_BLOCKY
blocky = ZMQ_BLOCKY,
#endif
#ifdef ZMQ_IO_THREADS
io_threads = ZMQ_IO_THREADS,
#endif
#ifdef ZMQ_THREAD_SCHED_POLICY
thread_sched_policy = ZMQ_THREAD_SCHED_POLICY,
#endif
#ifdef ZMQ_THREAD_PRIORITY
thread_priority = ZMQ_THREAD_PRIORITY,
#endif
#ifdef ZMQ_THREAD_AFFINITY_CPU_ADD
thread_affinity_cpu_add = ZMQ_THREAD_AFFINITY_CPU_ADD,
#endif
#ifdef ZMQ_THREAD_AFFINITY_CPU_REMOVE
thread_affinity_cpu_remove = ZMQ_THREAD_AFFINITY_CPU_REMOVE,
#endif
#ifdef ZMQ_THREAD_NAME_PREFIX
thread_name_prefix = ZMQ_THREAD_NAME_PREFIX,
#endif
#ifdef ZMQ_MAX_MSGSZ
max_msgsz = ZMQ_MAX_MSGSZ,
#endif
#ifdef ZMQ_ZERO_COPY_RECV
zero_copy_recv = ZMQ_ZERO_COPY_RECV,
#endif
#ifdef ZMQ_MAX_SOCKETS
max_sockets = ZMQ_MAX_SOCKETS,
#endif
#ifdef ZMQ_SOCKET_LIMIT
socket_limit = ZMQ_SOCKET_LIMIT,
#endif
#ifdef ZMQ_IPV6
ipv6 = ZMQ_IPV6,
#endif
#ifdef ZMQ_MSG_T_SIZE
msg_t_size = ZMQ_MSG_T_SIZE
#endif
};
#endif

Expand Down

0 comments on commit 5999e5a

Please sign in to comment.