VC6.0编写的MFC项目移植到VS2010中编译遇到的几个问题

来源:互联网 发布:java 根据域名获取ip 编辑:程序博客网 时间:2024/06/03 16:01

将VC6.0编写的一个项目移植到VS2010上编译,碰到了如下几个问题,简单记录一下:

1)首先修改程序配置,让默认的字符都为ANSI字符,VS2010默认为宽字符Unicode版。

项目右键属性—C/C++—Language—WChar_t—No,如图所示:

2)报错,找不到头文件winable.h

       Winable头文件从VS2008里面就已经不存在了,MSDN里描述如下:

       从 Visual Studio早期版本升级项目时,您可能必须修改 WINVER 和 _WIN32_WINNT 宏,以便它们大于或等于 0×0500。
       已移除 Windows API 头文件 Winable.h。而改为包括 Winuser.h。

3)语法错误,如下代码已经无法编译通过:

 

for(int i=0; i<10; i++){....}for (i=0; i<10; i++)
    

4)Compiler Error C2552 non-aggregates cannot beinitialized with initializer list 

      代码中使用了CString数组,定义的时候直接初始化,报如上错误。改为对数组成员一个个的初始化,则编译通过。

      搜到的相关解释如下:

      CompilerError C2552 non-aggregates cannot be initialized with initializer list. Thiserror beacuse of the following.....

      The specified identifier was incorrectly initialized.

      An initializer list is needed to initialize the following types:

     1) An array
     2) A class, structure, or union that does not have constructors, private orprotected members, base classes, or virtual functions
     These types are known as “aggregates.”


5)error C2440: 'static_cast' : cannot convertfrom 'void (__thiscall CTabSetDlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscallCWnd::* )(WPARAM,LPARAM)'

     消息响应函数的定义发生变化,需要修改相关函数的实现和声明。


原创粉丝点击