VS2003转换到VS2005的一些问题
2011-11-19 14:03
441 查看
1以前可以这样用try catch
catch(CException *e) {
pApp->Warn("%s",e->GetErrorMessage);
e->Delete();
return FALSE;
}
现在必须修改为:
catch(CException *e) {
TCHAR errormsg[255];
e->GetErrorMessage (errormsg,255,NULL);
pApp->Warn("%s",errormsg);
e->Delete();
return FALSE;
}
2 strchr必须强制转换一下。
以前可以 char *str2=strchr(line,'|');
2005必须 char *str2=(char *)strchr(line,'|');
1. lifescope of int i in for(int i; i< size; ++i)
in VC6, the codes below are ok
for(int i = 0; i< 10; ++i)
{
//...
}
for(i = 20; i< 40;++i)
{
//...
}
but in VS2005, we should write like below:
for(int i = 0; i< 10; ++i)
{
//...
}
for(int i = 20; i< 40;++i)
{
//...
}
in fact, from vs.net, the compiler accord with C++ standard more than VC6.
If you are porting a VC6 project to VS2005, you will encounter many many codes like this.
2. ON_WM_NCHITTEST (and other MFC macros) won't compile in VS2005
VS2005中,ON_WM_NCHITTEST宏编译不过
When I add a message handler of ON_WM_NCHITTEST to a CControlbar-derived class, it compiles error:
error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CMenuBar::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)' Cast from base to derived requires dynamic_cast or static_cast
To fix this bug, we should change the prototype of OnNcHitTest
from
afx_msg UINT OnNcHitTest(CPoint point);
to
afx_msg LRESULT OnNcHitTest(CPoint point);
3. VS2005中有些可能引起内存越界的函数不建议使用了
In VS2005, some dangerous functions are deprecated
char c[10];
strcpy(c, "testtestts"); //ok with VC6, but not in VS2005
strcpy_s(c, _countof(c),"testtestt");//9 chars, ok in VS2005
strcpy_s(c, _countof(c),"testtestt");//10 chars, assert!!!!! in VS2005
http://hi.baidu.com/yu_xiyan/blog/item/50d58b4e9ff310c1d0c86abc.html
catch(CException *e) {
pApp->Warn("%s",e->GetErrorMessage);
e->Delete();
return FALSE;
}
现在必须修改为:
catch(CException *e) {
TCHAR errormsg[255];
e->GetErrorMessage (errormsg,255,NULL);
pApp->Warn("%s",errormsg);
e->Delete();
return FALSE;
}
2 strchr必须强制转换一下。
以前可以 char *str2=strchr(line,'|');
2005必须 char *str2=(char *)strchr(line,'|');
1. lifescope of int i in for(int i; i< size; ++i)
in VC6, the codes below are ok
for(int i = 0; i< 10; ++i)
{
//...
}
for(i = 20; i< 40;++i)
{
//...
}
but in VS2005, we should write like below:
for(int i = 0; i< 10; ++i)
{
//...
}
for(int i = 20; i< 40;++i)
{
//...
}
in fact, from vs.net, the compiler accord with C++ standard more than VC6.
If you are porting a VC6 project to VS2005, you will encounter many many codes like this.
2. ON_WM_NCHITTEST (and other MFC macros) won't compile in VS2005
VS2005中,ON_WM_NCHITTEST宏编译不过
When I add a message handler of ON_WM_NCHITTEST to a CControlbar-derived class, it compiles error:
error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CMenuBar::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)' Cast from base to derived requires dynamic_cast or static_cast
To fix this bug, we should change the prototype of OnNcHitTest
from
afx_msg UINT OnNcHitTest(CPoint point);
to
afx_msg LRESULT OnNcHitTest(CPoint point);
3. VS2005中有些可能引起内存越界的函数不建议使用了
In VS2005, some dangerous functions are deprecated
char c[10];
strcpy(c, "testtestts"); //ok with VC6, but not in VS2005
strcpy_s(c, _countof(c),"testtestt");//9 chars, ok in VS2005
strcpy_s(c, _countof(c),"testtestt");//10 chars, assert!!!!! in VS2005
http://hi.baidu.com/yu_xiyan/blog/item/50d58b4e9ff310c1d0c86abc.html
相关文章推荐
- VC6 VS2003转换到VS2005中的一些问题
- vs2003转换成vs2005代码的问题
- VC6 和 VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- VC6 和 VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- VS2003 Project 转换成VS2005 Project遇到的问题
- VC6和VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- VC6 和 VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- 解决IE8下VS2005,VS2008一些向导提示脚本错误问题
- Directx SDK9.0b 中的程序在VS2005中编译中的一些问题
- 【原创】[C#]解决 vs2003 升级 vs2005 中文乱码问题
- 关于PHPExcel中日期转换遇到的一些问题
- vs2003升级到vs2005遇到的问题
- MySQL date/time 不能转换为 System.DateTime的问题[VS2005(C#)+mysql]
- 今天用VS2005编译DirectShow程序,一些莫名其妙的问题总结
- VC6\VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- compact framework 2.0 3.5 及vs2005 2008的一些问题
- 将Asp.net从VS2003以及VS2002工程转换为VS2005工程的简单而又行之有效的方法
- 转换程序的一些问题:设置为 OFF 时,不能为表 'Test' 中的标识列插入显式值。8cad0260
- MFC编程中遇到的一些字符串转换问题
- [转]VS2003 向 VS2005 过渡的问题