why( warning: left-hand operand of comma expression has no effect)

Colin McCabe cmccabe at alumni.cmu.edu
Mon Nov 19 19:20:44 CET 2012


You might be able to silence this with __attribute__((unused)), at
least for GCC and llvm.  Or possibly by making assert a multi-argument
macro...

Colin


On Fri, Nov 16, 2012 at 4:09 AM, Yoran Heling <info at yorhel.nl> wrote:
> On 2012-11-16, SmallAnt wrote:
>> i embed libev in my program,when compile,there are warnings:
>> ///
>> ./libev/ev_poll.c: In function `poll_poll':
>> ./libev/ev_poll.c:110: warning: left-hand operand of comma expression
>> has no effect
>> In file included from ohc_ev.c:7:
>> ./libev/ev.c: In function `verify_watcher':
>> ./libev/ev.c:2504: warning: left-hand operand of comma expression has no effect
>
> Just look at the source:
>
>   assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
>
> The string has absolutely no effect to the behaviour of the code, so the
> warning makes sense. However, that string *is* quite useful if the
> assertion fails: That string will be included in the output, so you'll
> (hopefully) know what went wrong without going through the source.
>
> In general, libev throws *tons* of compiler warnings. Some of them make
> sense, but they're also completely harmless. Just pass '-w' to the
> compiler to silence them for libev. (You probably don't want to do that
> for your own code, unless you care as much about compiler warnings as
> Marc does :-)
>
> Yoran.
>
> _______________________________________________
> libev mailing list
> libev at lists.schmorp.de
> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev



More information about the libev mailing list