[zeromq-dev] 0MQ 3.0 - API improvements

Pieter Hintjens ph at imatix.com
Thu Apr 7 16:07:01 CEST 2011


Hi Martin,

There's an aspect of the current API which is unfortunate, and causes
errors that could be avoided, and that's the use of 'void *' for
contexts and sockets.

This basically prevents the C/C++ compiler from type checking in many cases.

I'd suggest that zmq_context_t * and zmq_socket_t *, pointing to
opaque types, would be better and easier to work with.

In the zmq.h header,

//  Opaque structures
typedef struct _zmq_context_t zmq_context_t;
typedef struct _zmq_socket_t zmq_socket_t;

And in the source code:

struct _zmq_context_t {
    ... etc.
};

If the names are too long, zcontext_t and zsocket_t would be OK too.

-Pieter



More information about the zeromq-dev mailing list