책에 샘플 다음에 메시지 맵을 쓰려고했습니다.C++ : 배열, 이니셜 라이저 크기를 확인하지 못했습니다
여기 내 코드입니다 :
typedef struct MsgMapEntry_t {
UINT nMessage;
LONG (*pFunc)(HWND, UINT, WPARAM, LPARAM);
} MsgMapEntry_t;
// Skip Lines
LRESULT CALLBACK CyauShellWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static MsgMapEntry_t OnMsgMap[]=
(
// TODO Register MsgFunc here
WM_DESTROY, ExitApplication
);
그것을 컴파일하고 컴파일러에서 오류 밖으로 준다 :
D:\Projects\cyau\cyau_pre3_20120225\cyau_main.cpp:116:15: warning: left operand of comma operator has no effect [-Wunused-value]
D:\Projects\cyau\cyau_pre3_20120225\cyau_main.cpp:117:2: error: initializer fails to determine size of 'OnMsgMap'
그래서, 어떻게, 제발 정정합니다.
중첩 된 집계 이니셜 라이저가 "평평하게"허용되기 때문에 기술적으로 두 쌍이 필요하지 않습니다. – fredoverflow
오, 고마워. 그것은 작동합니다! – cuter44
@FredOverflow 당신은 맞습니다.하지만 "두 번째 요소를 내 배열에 추가하면 컴파일 오류가 발생하는 이유"라는 후속 질문을 피하기 위해 두 번째 쌍을 즉시 알려주는 것이 더 좋습니다. – dasblinkenlight