为方便起见,我想在此 GVEvent 联合中为内部 GVResponseEvent 使用 typedef。
我的尝试给了我编译错误:
warning C4091: 'typedef ' : ignored on left of '_GVEvent' when no variable is declared
error C2143: syntax error : missing ';' before '.'
error C2059: syntax error : '.'
我究竟做错了什么?
typedef struct {
int type ;
int status ;
} GVResponseEvent ;
typedef union _GVEvent {
int type ;
GVResponseEvent gvresponseevent;
} GVEvent ;
typedef GVEvent.GVResponseEvent resp_evt;
int main(int argc, char* argv[])
{
resp_evt.status = 9; *** not working
GVEvent myevt;
myevt.type = 2;
myevt.gvresponseevent.status = 9;
myevt.gvresponseevent.type = 8;
int gvresptype = myevt.gvresponseevent.type;
return 0;
}