VC6工程转VC9工程常见错误

来源:互联网 发布:软件库存 编辑:程序博客网 时间:2024/05/15 05:54

1. error C2065: 'i' : undeclared identifier

for循环体定义的循环变量只能在for循环体内使用。例如:

 

 

2. error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

static/register等变量类型以及函数返回值类型均不能缺省,例如:

 

 

3. error C2065: 'afxChNil' : undeclared identifier

函数GetPrivateProfileString的第三个参数可以为NULL了,不再需要“lpszDefault = &afxChNil;”。

4. LINK : fatal error LNK1181: cannot open input file 'ddraw.lib'

VS2008不再自带ddraw.lib,需要安装DirectX SDK。

5. error C2440: 'static_cast' : cannot convert from 'void (__thiscall CXXDlg::* )(BOOL,HTASK)' to 'void (__thiscall CWnd::* )(BOOL,DWORD)'
Cast from base to derived requires dynamic_cast or static_cast

一些消息函数的声明被改变了,例如ON_WM_ACTIVATEAPP,

VC6的版本:

VC9的版本:

6. error C2471: cannot update program database '…/debug/vc90.pdb'

VS2008的BUG,解决所有的编译错误后,Rebuild就没有了。

7. error C2383: default-arguments are not allowed on this symbol

函数指针的参数不能有缺省参数值。例如:

 

 

8. error C2039: 'ReadHuge' : is not a member of 'CFile'

CFile没有ReadHuge成员了,用Read就可以了。

9. 1>c:/program files/microsoft sdks/windows/v6.0a/include/ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
1> c:/program files/microsoft sdks/windows/v6.0a/include/winsock.h(460) : see previous definition of 'AF_IPX'
1>c:/program files/microsoft sdks/windows/v6.0a/include/ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
1> c:/program files/microsoft sdks/windows/v6.0a/include/winsock.h(460) : see previous definition of 'AF_IPX'

类似的错误和警告,都是因为混用了Winsock.h和Winsock2.h,如果说代码中没有找到相关#include语句,在工程设置C/C++ -> Advanced中打开Show Includes (/showIncludes) 来查看头文件的关联情况。

原创粉丝点击