
vc++常见错误提示.ppt
22页VC++常见错误提示计算系软件工程教研室 李典蔚 2009l 括号中的数字是出错的代码行的行号 例如错误中的第1行表示CalWnd.cpp的1092行出 现了错误如果想快速找到这行,可以在错误信息 行上双击鼠标,这时VC++会自动打开.cpp文件并 定位到这行 l 在错误信息行上按F1键,VC++会打开MSDN帮助 并显示关于该错误信息的一个简单的解释,你可以 根据该解释来知道到底是什么意思l Error后面的数字表示错误代号 错误代号分为两类: (1) C开头的是编译错误,即你的代码存在语法错误 ,你需要修改代码;语法错误分为一般错误( error)和警告错误(warning)两种2) LNK开头的是链接错误,通常你的代码并没有 语法错误,可能是配置错误引起的,一般是程序中 调用了某个函数,而链接程序却找不到该函数的定 义,但有时LNK也可能是由于拼写错误引起的另 外,程序分为几个文件分别编译、链接时,可能出 现全局变量没有声明或重复声明的错误l error C2011: 'C……': 'class' type redefinition 类“C……”重定义 l error C2018: unknown character '0xa3' 不认识的字符‘0xa3’。
一般是汉字或中文标点符 号,因为系统对中文环境下输入的符号,例如分号 括号等,系统是不接受的)l fatal error C1004: unexpected end of file found 解决方法:由于程序中少了 “)“ 或者 “}“ 之类的符号 ,编译器认为你的程序还没有写完.找出哪里漏掉了这 些符号,加上就可以了 l inta,b,max 提示:‘inta’ undeclared identifier l “int a”中“int”与“a”之间缺少空格l for(i==0;i就使用 printf和scanfl 提示:rand/NULL : unclared identifier l 不使用头文件包含命令#include就使用 rand和NULLl 提示:function 'void main(void)' already has a body 若同一程序中出现两次void main(void)l 提示:missing function header (old-style formal list?) 若程序中缺少void main(void)l LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 Debug/1.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe l 新建工程时,应选Win32 Console Application , 误选 Win32 Applicationl warning C4700: local variable 'bReset' used without having been initialized l 局部变量“bReset”没有初始化就使用。
l error C2509: 'OnTimer' : member function not declared in 'CHelloView' l 成员函数“OnTimer”没有在“CHelloView”中声明 l error C2511: 'reset': overloaded member function 'void (int)' not found in 'B' l 重载的函数“void reset(int)”在类“B”中找不到 l error C2555: ‘B::f1’: overriding virtual function differs from ‘A::f1’ only by return type or calling convention l 类B对类A中同名函数f1的重载仅根据返回值或调 用约定上的区别l typedef int DataType #include“seqlist.h“ error C2143: syntax error : missing ';' before '' fatal error C1004: unexpected end of file found Error executing cl.exe. l DataType后缺分号l #include“seqlist.h” l fatal error C1083: Cannot open include file: 'seqlist.h': No such file or directory Error executing cl.exe. l 找不到头文件l int Partition(SeqList *L,int low,int high); l {… …} l error C2447: missing function header (old- style formal list?) l 多分号,出现空语句l while(L->data[j]>=0 use parentheses to clarify precedence l 逻辑运算符 //Insert String …}; l void String::Inse(String l delete[]str; l } l error C2588: '::~String' : illegal global destructor l 类名及范围限定符String:: 漏写时报错:l error C2660: 'exit' : function does not take 0 parameters l 处理方法:在exit后加个(0)就行;l fatal error C1083: Cannot open precompiled header file: 'Debug/MyClock.pch': No such file or directory l 解决方法:可跳过COMPILE,直接进行BUILD, 或是关闭VC++6.0,重新打开。
l error C2664: '_wcsnicmp' : cannot convert parameter 2 from 'LPWORD' to 'const wchar_t *' l 需要强制类型转换l error C2061: syntax error : identifier not found 'HELPINFO‘ l 自己增加HELPINFO的类型,增加头文件 HelpInfo.h•Linking. error LNK2001: unresolved external symbol __endthreadex error LNK2001: unresolved external symbol __beginthreadex error LNK2001: unresolved external symbol _mainVC++默认的工程设置是单线程的,而你使用了多 线程,所以要修改设置选择菜单 “Project|settings”,选择C/C++标签,在CODE GENERATION分类中选择除SINGLE-THREADED 的其他选择或者是声明了别的函数,没有实现体 ,等等,2001问题很麻烦!l int EnumWindowsProc(HWND, long); l cannot convert parameter 1 from 'int (struct HWND__ *,long)' to 'int (__stdcall *)(struct HWND__ *,long)’l 实际应该定义为: int __stdcall EnumWindowsProc(HWND, long);。
