VC++编译错误集合

变量申明的时候初始化,指针使用的时候最好检查if(!p)else,否则很容易出现bug
1.

error C2668: 'memset' : ambiguous call to overloaded function
这说明memset 有多重意义,编译器不知道指的是那个,这种情况下,在memset 前加 :: 表示是全局的,或者在函数名前加上命名空间,道理是一样的


2.
fatal error C1001: INTERNAL COMPILER ERROR
这是VC6 的bug ,可以升级到 VC6 的SP6,这样就能解决,升级地址看下一篇blog


3.
perl_matcher_common.hpp(767) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'msc1.cpp', line 1794)
这个错误是使用Boost 的正则表达式库时经常会出现的一个错误,但这个错误实际上并不影响结果,遇到这个错误的时候 Rebuild All 一下就可以了。


4.
Command line error D2016 : '/ZI' and '/O2' command-line options are incompatible
这实际上是编译参数冲突,/ZI 和 /O2 删除其中一个就OK,可以参看 MSDN 中各编译参数


5.
error C2079: 'hints' uses undefined struct 'addrinfo'
如果头文件包含了  winsock2.h   Ws2tcpip.h   加载DLL   #pragma comment(lib,"ws2_32.lib")  那么,这个错误通常是SDK库需要更新,问题解决请参考:
http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/a4dc0b8d-7e6f-4c75-834b-16faebb96c0d
更新 SDK 库:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
根据上述地址下载完,然后根据下载页面上的说明安装,安装过程中可能会遇到 【Automation 服务器不能创建对象】的错误,这时需要注册一个DLL,在运行中输入  regsvr32 scrrun.dll  这样就OK 了
将 SDK 库安装完成之后,在 Tools->Option->Directories    Include files 中添加 SDK 中的 include 目录,SDK 中 include 在前,VC98 中 include 目录在后


6.
error C2065: 'bcmp' : undeclared identifier
如果包含了 string.h 则,出现这个错误时因为 bcmp 是 linux 上的,Win32 下用 memcmp 即可


7.
fatal error LNK1104: cannot open file "Psapi.Lib"
出现这个情况需要升级 SDK ,如 5,然后包含 lib 目录到 Tools->Option->Directories->Library files


8.
error LNK2001: unresolved external symbol __CrtDbgReport
Project -> Setting -> Co

de Generation -> 多线程模式就 OK

9.
error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'
这种情况是在 CreateThread 的时候出现的,线程函数不能为局部函数,所以,可以将线程函数声明为 static 或者干脆弄成全局函数就 OK 了。如果使用静态函数,则因为静态函数中只能使用静态成员变量或者全局成员变量,所以,这个也需要注意。

10.
error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned
int,unsigned int,long)'

这是因为 DialogProc 的返回值引起的问题,返回值应该为 INT,而不是 INT_PTR


11.

tlhelp32.h(24) : error C2146: syntax error : missing ';' before identifier 'WINAPI'

tlhelp32.h(24) : error C2501: 'HANDLE' : missing storage-class or type specifiers

tlhelp32.h(24) : fatal error C1004: unexpected end of file found

这些错误的出现是因为没有引入 Windows.h 头文件引起的

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值