我正在阅读 Libevent2.0 的源代码,我发现下面有一些我无法理解的代码。为什么我们可以访问成员“ev_ncalls”而不访问“_ev”和“ev_signal”?我编译了一些无法通过 gcc 的代码。这是代码:
struct event {
union {
/* used for io events */
struct {
TAILQ_ENTRY(event) ev_io_next;
struct timeval ev_timeout;
} ev_io;
/* used by signal events */
struct {
TAILQ_ENTRY(event) ev_signal_next;
short ev_ncalls;
/* Allows deletes in callback */
short *ev_pncalls;
} ev_signal;
} _ev;
};
struct event *ev;
int ncall = ev->ev_ncalls;