| 錯誤代碼 | 英文信息 | 中文含義 | 典型原因與修復 |
| C1010 | unexpected end of file while looking for precompiled header directive | 尋找預編譯頭時遇到文件尾 | 缺少 #include "stdafx.h" 或順序錯誤。確保 stdafx.h 為第一個非註釋 include。 |
| C1083 | Cannot open include file: 'xxx.h': No such file or directory | 無法打開包含文件 | 頭文件路徑未加入「附加包含目錄」,或文件名拼寫錯誤/大小寫敏感(跨平台)。 |
| C2011 | 'C...' : 'class' type redefinition | 類重複定義 | 頭文件缺少防重復包含宏(#pragma once 或 #ifndef/define/endif),或 cpp 互相 include。 |
| C2018 | unknown character '0xa3' | 無法識別字符 | 源碼中混入中文字符/全角標點(如在字符串外)。檢查編碼,改用英文半角或資源字符串。 |
| C2057 | expected constant expression | 期望常量表達式 | switch 的 case 後跟非常量(變量/函數調用)。僅允許整型常量/枚舉/宏。 |
| C2065 | 'IDD_MYDIALOG' : undeclared identifier | 未聲明的標識符 | 資源 ID 未定義(Resource.h 未包含/未同步),或拼寫錯誤。 |
| C2082 | redefinition of formal parameter 'bReset' | 函數參數在函數體中重定義 | 參數名與局部變量名衝突。重命名局部變量。 |
| C2143 | syntax error : missing ';' before '{' | 語法錯誤:'{' 前缺少 ';' | 結構體/類定義結尾漏分號,或宏展開後語法不全。 |
| C2146 | syntax error : missing ';' before identifier 'dc' | 語法錯誤:標識符前缺少 ';' | 上一語句漏分號,導致編譯器以為在聲明新變量。 |
| C2196 | case value '69' already used | case 值已使用 | switch 中重複 case 常量值。 |
| C2509 | 'OnTimer' : member function not declared in 'CHelloView' | 成員函數未在類中聲明 | 類向導添加消息處理失敗,或手動添加函數未在頭文件聲明。用類向導重新添加。 |
| C2511 | 'reset' : overloaded member function not found in 'B' | 重載成員函數在類中找不到 | 派生類重寫虛函數簽名與基類不匹配(參數/const/引用差異)。 |
| C2555 | overriding virtual function differs only by return type or calling convention | 重寫虛函數僅返回類型/調用約定不同 | C++ 不允許僅靠返回類型重載/重寫。修正簽名一致。 |
| C2660 | 'SetTimer' : function does not take 2 parameters | 函數參數個數不匹配 | 調用參數數量與聲明不符。查閱 MSDN 確認正確原型(如 SetTimer 需 4 參數)。 |
| C4035 (W) | 'f...' : no return value | 函數無返回值(警告) | 非 void 函數所有路徑必須 return。補全返回語句。 |
| C4553 (W) | '==' : operator has no effect; did you intend '='? | == 無效果,意圖為 =? | 條件判斷寫成賦值,或賦值寫成判斷。檢查邏輯。 |
| C4700 (W) | local variable 'bReset' used without having been initialized | 局部變量未初始化即使用 | 聲明後未賦值即讀取。定義時初始化 int x = 0;。 |
| C4716 | 'CMyApp::InitInstance' : must return a value | 函數必須返回值 | 非 void 函數缺少 return。MFC 覆寫函數必須返回 BOOL。 |
| LNK1168 | cannot open Debug/xxx.exe for writing | 無法打開 exe 寫入 | 程序正在運行(進程未退出),或殺毒軟件攔截。任務管理器結束進程/排除目錄。 |
| LNK2001 | unresolved external symbol "public: virtual __thiscall C...::~C...(void)" | 未解析的外部符號 | 聲明了虛函數(常為析構函數)但未定義實現。補上函數體,哪怕為空。 |