[zeromq-dev] Unused variable

Luca Fascione lukes at wetafx.co.nz
Mon Feb 13 02:32:50 CET 2012

Hey guys,
there's a couple instances in zmq.hpp that include a pattern like this:

         inline ~message_t ()
             int rc = zmq_msg_close (&msg);
             assert (rc == 0);

in which a variable (rc in this case) is allocated for the sole purpose 
of being tested in an assert.

As we compile with high warning levels, these variables turn into 
warnings such as this:

.../zeromq-2.1.10/include/zmq.hpp: In destructor 
.../zeromq-2.1.10/include/zmq.hpp:108: warning: unused variable 'rc' 

which are annoying, especially in an otherwise clean build. I would like 
to mark these variables unused in the code,
but I'm a little unsure how you guys would like to see it done.
It seems the way would be to add to zmq.h

/*  Mark variables unused to quiet warnings */
#define ZMQ_UNUSED(x) (void)sizeof(x)

and then change the method above into this:

         inline ~message_t ()
             int rc = zmq_msg_close (&msg);
             assert (rc == 0);

if this sounds allright I'll submit a pull request in the near future

Luca Fascione
Rendering Research Lead - Weta Digital
Phone:  +64  4 909 6870 (x6870)
Mobile: +64 21 0764 862

More information about the zeromq-dev mailing list