今天看libevent源码的时候,看到struct evmap_io结构体,改结构体内容如下:
struct evmap_io {
struct event_dlist events;
ev_uint16_t nread;
ev_uint16_t nwrite;
ev_uint16_t nclose;
};
里面第一个类型是struct event_dlist,但是用sourceinsight看代码时看不到该结构体的定义,后来百度谷歌也都没发现原因。没办法,全局找了一下,最后发现有这么个定义,
LIST_HEAD (event_dlist, event);
然后追了下LIST_HEAD的宏定义,
#define LIST_HEAD(name, type) \
struct name { \
struct type *lh_first; /* first element */ \
}
这才搞明白原来是在这里定义的。
感觉libevent用了太多的宏了,源码看起来有点费劲。