"subclassing" the watcher

Kandalintsev Alexandre urao at messir.net
Thu Sep 11 13:03:59 CEST 2008


Hello!

I've got problem with example from manpage.
According to manual its possible to write
this code(example from section "ASSOCIATING
CUSTOM DATA WITH A WATCHER":

#include <ev.h>

struct my_io
{
     struct ev_io io;
     int otherfd;
     void *somedata;
     struct whatever *mostinteresting;
} stdin_watcher;

stdin_cb (EV_P_ struct ev_io *w_, int revents) {
     struct my_io *w = (struct my_io *)w_;
}

int main(void) {
     struct ev_loop *loop = ev_default_loop(0);
     ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ);
     ev_io_start (loop, &stdin_watcher);

     ev_loop (loop, 0);

     return 0;
}



But it's not working:
./test.c: In function ‘main’:
./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?

---
//Kandalintsev Alexandre



More information about the libev mailing list