我有这段代码:
static char szTop[] = "iMsg wParam lParam";
static char szUnd[] = "____ ______ ______";
static char szFormat[] = "%-16s%04X-%04X %04X-%04X";
static char szBuffer[50];
static HWND hwndButton[NUM];
它给了我错误:
error C2143: syntax error : missing ']' before ';'
error C2143: syntax error : missing ';' before ']'
另一个代码是:
for(i=0;i<NUM;i++)
hwndButton[i] = CreateWindow ( "button", button[i].text, WS_CHILD | WS_VISIBLE | button[i].style, cxChar, cyChar * (1+2*i), 20*cxChar, 7*cyChar/4, hwnd, (HMENU) i, ((LPCREATESTRUCT) lParam )->hInstance, NULL );
return 0;
这给了我错误:
error C2146: syntax error : missing ')' before identifier 'i'
error C2059: syntax error : ';'
error C2059: syntax error : ')'
error C2146: syntax error : missing ';' before identifier 'hwndButton
我之前已将所需内容定义为:
static char szTop[] = "iMsg wParam lParam";
static char szUnd[] = "____ ______ ______";
static char szFormat[] = "%-16s%04X-%04X %04X-%04X";
static char szBuffer[50];
static HWND hwndButton[NUM];
static RECT rect;
static int cxChar,cyChar;
HDC hdc;
PAINTSTRUCT ps;
int i;
TEXTMETRIC tm;
答案 0 :(得分:0)
对于第一个,这可能是因为没有针对类型或宏定义,很可能是HWND
或NUM
。
对于第二个,它抱怨在定义它之前使用hwndButton
,仅仅因为第一个错误 - 该变量从未被定义,因为试图定义它的语句具有较早的错误错误。 / p>
首先,确认您已包含正确的标头。我认为它在windef.h
中,但通常包含在windows.h
头文件中。
其次,确保NUM
实际上已在某处定义。
我认为它可能是NUM
,因为其中一个错误来自for
循环语句,其中windows.h
内容未使用但NUM
是。< / p>