Suggestion for libev man page

MONGIOVI, ROY rx5330 at
Fri Jan 13 20:49:14 CET 2017

In the section titled "Building your own composite watchers" the man page suggests putting several watchers in a single structure and then using offsetof within each watcher to compute back to the beginning of the containing structure.  That seems overly obscure to me, not to mention that it makes the code extremely fragile to changes in the containing structure.  I think that this is an unnecessary complication.

Each watcher already has a void *data variable allocated which in this example is unused.  Just store a pointer to the containing structure in each watcher's data variable.  Then cast the data pointer to the containing structure type exactly as is done with the watcher pointer in the previous section "Associating custom data with a watcher."  That's much clearer than offsetof.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the libev mailing list