> 1) zmq.h would define ZMQ_VERSION to be some magic (opaque) constant that > incorporates the major, minor and patch versions; the constants should be > arithmetically comparable; i.e. something like what Gonzalo proposed. > > 2) it would also define a ZMQ_MAKE_VERSION(major,minor,patch) macro that > would evaluate to the ZMQ_VERSION constant which the user passed in as > parameters. > > This would allow for clear code like: > > #if ZMQ_VERSION >= ZMQ_MAKE_VERSION(2,1,0) && > ZMQ_VERSION < ZMQ_MAKE_VERSION(3,0,0) > // Something specific to 0MQ versions newer than 2.1.0 but not 3.x. > #endif > > Comments?
Yes, this is even nicer (I think). In short: // These are the ONLY numbers you have to manually maintain: #define ZMQ_VERSION_MAJOR 2 #define ZMQ_VERSION_MINOR 0 #define ZMQ_VERSION_PATCH 1 // Everything in a single numeric value, easy for comparison: #define ZMQ_VERSION_BUILD(j,n,t) (((j*100)+n)*100+t) // Current version: #define ZMQ_VERSION_CURRENT ZMQ_VERSION_BUILD(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH) // These are for bindings that make this decision at run-time: int zmq_version_major() { return ZMQ_VERSION_MAJOR; } int zmq_version_minor() { return ZMQ_VERSION_MINOR; } int zmq_version_patch() { return ZMQ_VERSION_PATCH; } int zmq_version_current() { return ZMQ_VERSION_CURRENT; } -- Gonzalo Diethelm _______________________________________________ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev