常見的C++編譯錯誤

來源:http://bbs.51cto.com/thread-504741-1-1.html

1、fatal error C1010: unexpected end of file while looking for precompiled header directive。

尋找預編譯頭文件路徑時遇到了不該遇到的文件尾。(一般是沒有#include "stdafx.h")
( Z+ v8 }% f  \" k; J6 L
2、fatal error C1083: Cannot open include file: 'R…….h': No such file or directory4 u1 |' ~' l% S  `
不能打開包含文件“R…….h”:沒有這樣的文件或目錄。" O: X) q' X, G/ z' \* a3 y
: r2 Z2 u8 c' U( T: F* l9 `7 X
3、error C2011: 'C……': 'class' type redefinition
類“C……”重定義。

4、error C2018: unknown character '0xa3'
不認識的字符'0xa3'。(一般是漢字或中文標點符號)

5、error C2057: expected constant expression
希望是常量表達式。(一般出現在switch語句的case分支中)

6、error C2065: 'IDD_MYDIALOG' : undeclared identifier& r0 t, l% M  j. w. ~
“IDD_MYDIALOG”:未聲明過的標識符。

7、error C2082: redefinition of formal parameter 'bReset'" [. _: x% K! o' c+ I- d7 v  }
函數參數“bReset”在函數體中重定義。
- k( S& A4 c! r8 r4 d( c: u
8、error C2143: syntax error: missing ':' before '{'
句法錯誤:“{”前缺少“;”。

9、error C2146: syntax error : missing ';' before identifier 'dc'9 O; ]7 }6 K# ~
句法錯誤:在“dc”前丟了“;”。
8 D- U% K+ W  L5 r0 a
10、error C2196: case value '69' already used) U5 I) _" R' q4 v1 T9 `% Z
值69已經用過。(一般出現在switch語句的case分支中)
- Q+ E& a/ a: {9 |+ E! H$ D) G
11、error C2509: 'OnTimer' : member function not declared in 'CHelloView'9 g4 D+ n$ e0 ?* r+ l
成員函數“OnTimer”沒有在“CHelloView”中聲明。
" {/ V& O% ~( k1 a. u1 M  v2 t
12、error C2511: 'reset': overloaded member function 'void (int)' not found in 'B'1 w* Z, b" a3 r7 r, p
重載的函數“void reset(int)”在類“B”中找不到。. o3 t% ]! z' Q. H7 z0 J6 K- M
7 ~% A1 K8 p# s) |# g% o( T
13、error C2555: 'B::f1': overriding virtual function differs from 'A::f1' only by return type or calling convention, O# F6 ~( D  L8 Z4 y9 M' o$ U
類B對類A中同名函數f1的重載僅根據返回值或調用約定上的區別。0 N3 m! Y! ?; X
# V: A" J7 N% ~6 F8 D: _( V( h
14、error C2660: 'SetTimer' : function does not take 2 parameters0 s" D# B, M2 T/ j! y
“SetTimer”函數不傳遞2個參數。+ }4 X: p# y% K+ u% e0 ^4 g' y9 j

15、warning C4035: 'f……': no return value
“f……”的return語句沒有返回值。
. A/ X( ?" H* @
16、warning C4553: '= =' : operator has no effect; did you intend '='?
沒有效果的運算符“= =”;是否改爲“=”?
1 e: x% K$ j8 [8 O/ Q% L( m6 c
17、warning C4700: local variable 'bReset' used without having been initialized
局部變量“bReset”沒有初始化就使用。
# a. t' J7 D5 k  H3 C9 i
18、error C4716: 'CMyApp::InitInstance' : must return a value$ f" Z2 M( C6 |! ~4 ?
“CMyApp::InitInstance”函數必須返回一個值。& `4 r0 L; i) s2 B
, W4 O- F8 s3 ^7 _
19、LINK : fatal error LNK1168: cannot open Debug/P1.exe for writing. [7 N2 Y& ~# T: ?0 U
連接錯誤:不能打開P1.exe文件,以改寫內容。(一般是P1.Exe還在運行,未關閉)
  s' k+ i' ~* O; u# }! a! f
20、error LNK2001: unresolved external symbol "public: virtual _ _thiscall C……::~C……(void)"
連接時發現沒有實現的外部符號(變量、函數等)。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章