Skip to content

Commit f428fee

Browse files
authored
Problem: zmq_fd_t not used/available in zmq (#452)
* Problem: zmq_fd_t not used/available in zmq Solution: Make zmq::fd_t available and use in poller_event * Deprecate typedef with comment
1 parent c591113 commit f428fee

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

tests/socket.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ TEST_CASE("socket check integral options", "[socket]")
270270
check_integral_opt_get<int>(zmq::sockopt::events, router, "events");
271271
#endif
272272
#ifdef ZMQ_FD
273-
check_integral_opt_get<zmq::sockopt::cppzmq_fd_t>(zmq::sockopt::fd, router,
274-
"fd");
273+
check_integral_opt_get<zmq::fd_t>(zmq::sockopt::fd, router, "fd");
275274
#endif
276275
#ifdef ZMQ_HANDSHAKE_IVL
277276
check_integral_opt<int>(zmq::sockopt::handshake_ivl, router, "handshake_ivl");

zmq.hpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,17 @@ struct is_range<
273273
typedef zmq_free_fn free_fn;
274274
typedef zmq_pollitem_t pollitem_t;
275275

276+
// duplicate definition from libzmq 4.3.3
277+
#if defined _WIN32
278+
#if defined _WIN64
279+
typedef unsigned __int64 fd_t;
280+
#else
281+
typedef unsigned int fd_t;
282+
#endif
283+
#else
284+
typedef int fd_t;
285+
#endif
286+
276287
class error_t : public std::exception
277288
{
278289
public:
@@ -1351,10 +1362,6 @@ constexpr const_buffer operator"" _zbuf(const char32_t *str, size_t len) noexcep
13511362
}
13521363
}
13531364

1354-
#endif // ZMQ_CPP11
1355-
1356-
1357-
#ifdef ZMQ_CPP11
13581365
namespace sockopt
13591366
{
13601367
// There are two types of options,
@@ -1390,16 +1397,8 @@ template<int Opt, int NullTerm = 1> struct array_option
13901397
using NAME##_t = array_option<OPT, 2>; \
13911398
ZMQ_INLINE_VAR ZMQ_CONSTEXPR_VAR NAME##_t NAME {}
13921399

1393-
// duplicate definition from libzmq 4.3.3
1394-
#if defined _WIN32
1395-
#if defined _WIN64
1396-
typedef unsigned __int64 cppzmq_fd_t;
1397-
#else
1398-
typedef unsigned int cppzmq_fd_t;
1399-
#endif
1400-
#else
1401-
typedef int cppzmq_fd_t;
1402-
#endif
1400+
// deprecated, use zmq::fd_t
1401+
using cppzmq_fd_t = ::zmq::fd_t;
14031402

14041403
#ifdef ZMQ_AFFINITY
14051404
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_AFFINITY, affinity, uint64_t);
@@ -1435,7 +1434,7 @@ ZMQ_DEFINE_ARRAY_OPT_BIN_OR_Z85(ZMQ_CURVE_SERVERKEY, curve_serverkey);
14351434
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_EVENTS, events, int);
14361435
#endif
14371436
#ifdef ZMQ_FD
1438-
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_FD, fd, cppzmq_fd_t);
1437+
ZMQ_DEFINE_INTEGRAL_OPT(ZMQ_FD, fd, ::zmq::fd_t);
14391438
#endif
14401439
#ifdef ZMQ_GSSAPI_PLAINTEXT
14411440
ZMQ_DEFINE_INTEGRAL_BOOL_UNIT_OPT(ZMQ_GSSAPI_PLAINTEXT, gssapi_plaintext, int);
@@ -2587,11 +2586,7 @@ struct no_user_data;
25872586
template<class T = no_user_data> struct poller_event
25882587
{
25892588
socket_ref socket;
2590-
#ifdef _WIN32
2591-
SOCKET fd;
2592-
#else
2593-
int fd;
2594-
#endif
2589+
::zmq::fd_t fd;
25952590
T *user_data;
25962591
event_flags events;
25972592
};

0 commit comments

Comments
 (0)