1. error C2065: 'i' : undeclared identifier
for循环体定义的循环变量只能在for循环体内使用。例如:
for (int i=0; …) { } for (i=0; …) { // C2065 } for (int i=0; …) { // OK }
2. error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
static/register等变量类型以及函数返回值类型均不能缺省,例如:
static count = 0; // C4430 static int count = 0; // OK
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的版本:
afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
VC9的版本:
afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID);
6. error C2471: cannot update program database '…/debug/vc90.pdb'
VS2008的BUG,解决所有的编译错误后,Rebuild就没有了。
7. error C2383: default-arguments are not allowed on this symbol
函数指针的参数不能有缺省参数值。例如:
void (*pf)(int = 0); // C2383 void (*pf)(int); // OK typedef long (CALLBACK* LPFNFUNCNAME)(int val = 0); // C2383 typedef long (CALLBACK* LPFNFUNCNAME)(int val); // OK
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) 来查看头文件的关联情况。