"subclassing" the watcher

Marc Lehmann schmorp at schmorp.de
Sat Sep 13 20:19:54 CEST 2008


On Thu, Sep 11, 2008 at 03:03:59PM +0400, Kandalintsev Alexandre <urao at messir.net> wrote:
> According to manual its possible to write
> this code(example from section "ASSOCIATING
> CUSTOM DATA WITH A WATCHER":

You must have misread something, the documentation never tells you that
using a different type for a watcher argument works.

>     ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ);

stdin_watcher is not of type ev_io, you have to use &stdin_watcher.io here
if you want that.

> ./test.c:17: error: ‘struct my_io’ has no member named ‘cb’
> ./test.c:17: error: ‘struct my_io’ has no member named ‘fd’
> ./test.c:17: error: ‘struct my_io’ has no member named ‘events’
>
> How to fix this problem?

Use the correct types - ev_io_* requires an ev_io * as first argument, as in
the example above.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at goof.com
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list