[zeromq-dev] Unused variable

Nadav Samet thesamet at gmail.com
Mon Feb 13 02:37:41 CET 2012


I encountered the same issue a while ago and sent a pull request through
github, but I forgot to follow up on this.

https://github.com/zeromq/zeromq2-2/pull/2


On Sun, Feb 12, 2012 at 5:32 PM, Luca Fascione <lukes at wetafx.co.nz> wrote:

> 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
> 'zmq::message_t::~message_t()':
> .../zeromq-2.1.10/include/zmq.hpp:108: warning: unused variable 'rc'
> [-Wunused-variable]
>
> 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);
>             ZMQ_UNUSED(rc);
>             assert (rc == 0);
>         }
>
> if this sounds allright I'll submit a pull request in the near future
> Luca
>
> --
> Luca Fascione
> Rendering Research Lead - Weta Digital
> Phone:  +64 4 909 6870 (x6870)
> Mobile: +64 21 0764 862
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



-- 
-Nadav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120212/b9e44722/attachment.htm>


More information about the zeromq-dev mailing list