以多文档MFC程序为例,说明怎么从VC 6.0升级到VC 2003:
1.VC 6.0建好的Project用.NET打开出现好多Warnings。首先看看代码的差别。
(1)XXX.cpp中。
在.Net中:
BOOL CXXXApp::InitInstance()
{
InitCommonControls();
CWinApp::InitInstance();
// 初始化 OLE 库
if (!AfxOleInit())
{ AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
……
}
而在VC 6.0中为:
BOOL CXXXApp::InitInstance()
{
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
……
}
所以第一步,将VC 6.0不同于VC 2003中的代码修改。需要在resource.h中增加定义:
#define IDP_OLE_INIT_FAILED 100
(2)stdAfx.h文件
在.Net中
……
#ifndef WINVER // 允许使用 Windows 95 和 Windows NT 4 或更高版本的特定功能。
#define WINVER 0x0400 //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。
#endif
#ifndef _WIN32_WINNT // 允许使用 Windows NT 4 或更高版本的特定功能。
#define _WIN32_WINNT 0x0400 //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。
#endif
#ifndef _WIN32_WINDOWS // 允许使用 Windows 98 或更高版本的特定功能。
#define _WIN32_WINDOWS 0x0410 //为 Windows Me 及更新版本改变为适当的值。
#endif
#ifndef _WIN32_IE // 允许使用 IE 4.0 或更高版本的特定功能。
#define _WIN32_IE 0x0400 //为 IE 5.0 及更新版本改变为适当的值。
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
……
而在VC 6.0中没有这些宏定义。
修改之二为:一般在stdAfx.h中增加WINVER定义就够了。
#define WINVER 0x0400 //为 Windows98 和 Windows 2000 及更新版本改变为适当的值。
2. LINK : warning LNK4075: 忽略“/EDITANDCONTINUE”(由于“/INCREMENTAL:NO”规范)
解决办法:
属性,链接器,常规,启动增量链接 选择 是(INCREMENTAL)
另外也有人做法为:选择项目,属性->配置属性->C/C++->常规 修改 调试信息格式 为 程序数据库(/Zi)
3.其他的修改以后遇到再说……
浙公网安备 33010602011771号