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

Yoran Heling info at yorhel.nl
Fri Nov 16 13:09:00 CET 2012


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.



More information about the libev mailing list