On 20/02/18 10:17, Marc Lehmann wrote:
On Tue, Feb 20, 2018 at 12:40:38AM +0800, Andy Green <a...@warmcat.com> wrote:
You sound confident about that, but actually having implemented it, you have 
not considered that the structures composing event lib state (handles, loop 
objects etc) must be defined in one place with types available for all event 
libs simultaneously.

Not really, even C supports opaque types.

No, there is no "not really" about it.

C supports opaque type pointers because the size of a pointer is known regardless of the details of what it points to.

However you cannot compose an opaque / forward-referenced struct into another struct with type safety, because the size of the undefined thing is unknown.

For example you do this:

typedef struct ev_io

  int fd;     /* ro */
  int events; /* ro */
} ev_io;

and I do this

struct lws_io_watcher {
        ev_io ev_watcher;
        uv_poll_t uv_watcher;
        struct event *event_watcher;
        struct lws_context *context;

        uint8_t actual_events;

I must have your struct definition and that means I must have your headers.


libev mailing list

Reply via email to