VC6 VS2003转换到VS2005中的一些问题
2007-03-20 15:44
260 查看
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
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
相关文章推荐
- VS2003转换到VS2005的一些问题
- VC6 和 VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- VC6和VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- VC6 和 VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- vs2003转换成vs2005代码的问题
- VS2003 Project 转换成VS2005 Project遇到的问题
- VC6 和 VS2003 转换到VS2005 时可能会遇到的问题以及解决方法
- VC6 vs2003 vs2005 shortcut 工程中文件说明 一些基本技巧
- 我们在写程序时,常常会遇到类型转换的问题。现总结一些常见的类型转换。
- .net C++ 的一些问题(vs2003)
- IOS将字符串转换为日期时间格式的一些问题
- vs2003 mfc项目转换为vs2010项目遇到的问题
- python一些编码的转换格式问题
- java中一些int,String,byte的转换问题
- MFC在共享DLL中使用转换为静态库中使用的一些问题
- sqlserver的timestamp在类型转换y杜鳌这个问的一些小问题
- vs2003入门一些问题搜集解决办法整理20090220
- SQL Server 2008 转换为 SQL 2005 数据库的一些问题
- 从MPG切割,合并到转换成FLV视频过程中可能遇到的一些问题(主要用到mencoder ffmpeg flvtool2)
- 从vc6迁移到vs2005过程中的问题(学习过程中逐渐添加)