代碼:
int x = 6;
if (bFlag)
x = 8;
int y = 6;
VS2005編譯報錯: error C2143: syntax error : missing ';' before 'type'
報錯位置: int y = 6;
去掉 if(bFlag)
x = 8;
編譯成功,這不應該啊,沒有語法錯誤。
最後去掉 int y = 6;中的 int編譯通過。
給出的解釋:
In Microsoft C, compiler errors C2143 and C2144 are defined as follows:
C2144: syntax error : missing 'token' before type 'type'
You may receive this error message if your program places executable code before a data declaration, an acceptable practice in Kernighan-and-Ritchie C. This practice has been outlawed in later versions of the ANSI drafts.
This error message will normally occur if a required closing curly brace (}), right parenthesis [)], or semicolon (;) is missing.