在迁移一个CRC32程序时,遇到如下问题:
编译日志:
1>------ Rebuild All started: Project: CRCThread, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'CRCThread', configuration 'Debug|Win32'
1>Compiling...
1>StdAfx.cpp
1> WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
1>Compiling...
1>CRC_32.cpp
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\crc_32.cpp(95) : warning C4996: '_sopen': This function or variable may be unsafe. Consider using _sopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 8\vc\include\io.h(255) : see declaration of '_sopen'
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\crc_32.cpp(311) : warning C4996: '_tcsncpy': This function or variable may be unsafe. Consider using _tcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 8\vc\include\tchar.h(1518) : see declaration of '_tcsncpy'
1>CRCThread.cpp
1> WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\crcthread.cpp(52) : warning C4996: 'CWinApp::Enable3dControls': CWinApp::Enable3dControls is no longer needed. You should remove this call.
1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(4477) : see declaration of 'CWinApp::Enable3dControls'
1>CRCThreadDlg.cpp
1> WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\crcthreaddlg.cpp(103) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CCRCThreadDlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>FileEditCtrl.cpp
1> WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\fileeditctrl.cpp(277) : error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CFileEditCtrl::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)'
1> Cast from base to derived requires dynamic_cast or static_cast
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\fileeditctrl.cpp(285) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CFileEditCtrl::* )(UINT,LPCTSTR)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\fileeditctrl.cpp(1897) : warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized
1>PJA_Icon.cpp
1> WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
1>TextProgressCtrl.cpp
1> WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\textprogressctrl.cpp(157) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CTextProgressCtrl::* )(UINT,LPCTSTR)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\textprogressctrl.cpp(158) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CTextProgressCtrl::* )(UINT,LPTSTR)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\textprogressctrl.cpp(165) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CTextProgressCtrl::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\textprogressctrl.cpp(166) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CTextProgressCtrl::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>d:\mydoc09\visual studio 2005\projects\crc32\codeproject2\crc_32_demo\textprogressctrl.cpp(170) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CTextProgressCtrl::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
1> None of the functions with this name in scope match the target type
1>Generating Code...
1>Build log was saved at "file://d:\mydoc09\Visual Studio 2005\Projects\crc32\codeproject2\CRC_32_Demo\Debug\BuildLog.htm"
1>CRCThread - 8 error(s), 4 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
其中的错误大多与"
error C2440: 'static_cast' : cannot convert from
"静态转换有关。
主要说某个参数无法转换到另一个类型。
看MSDN关于消息影射相关规定:
Map entry
|
Function prototype
|
ON_MESSAGE( <message>, <memberFxn> )
|
afx_msg LRESULT memberFxn( WPARAM, LPARAM );
|
ON_REGISTERED_MESSAGE( <nMessageVariable>, <memberFxn> )
|
afx_msg LRESULT memberFxn( WPARAM, LPARAM );
|
ON_THREAD_MESSAGE( <message>, <memberFxn> )
|
afx_msg void memberFxn( WPARAM, LPARAM );
|
ON_REGISTERED_THREAD_MESSAGE( <nMessageVariable>, <memberFxn> )
|
afx_msg void memberFxn( WPARAM, LPARAM );
|
一、简单升级错误:
1)OnSetText
原声明:afx_msg LRESULTOnSetText(UINT, LPCTSTR)
更改为:afx_msgLRESULTOnSetText(WPARAM, LPARAM)
2)OnCRCThreadDone
原声明:afx_msg void OnCRCThreadDone(WPARAM, LPARAM);
更改为:afx_msg LRESULT OnCRCThreadDone(WPARAM, LPARAM);
3)OnGetText
原声明:afx_msg LRESULT OnGetText(UINT cchTextMax, LPTSTR szText);
更改为:afx_msg LRESULT OnGetText(WPARAM cchTextMax, LPARAM szText);
4)OnSetRange
原声明:afx_msg void OnSetRange(WPARAM, LPARAM range);
更改为:afx_msg LRESULT OnSetRange(WPARAM, LPARAM range);
5)OnSetRange32
原声明:afx_msg void OnSetRange32(WPARAM lower, LPARAM higher);
更改为:afx_msg LRESULT OnSetRange32(WPARAM lower, LPARAM higher);
6)OnSetShowText
原声明:afx_msg void OnSetShowText(WPARAM bShow, LPARAM);
更改为:afx_msg LRESULT OnSetShowText(WPARAM bShow, LPARAM);
二、VC系统函数更改后的错误
1)ON_WM_NCHITTEST
出现这个错误的原因可是“人力不可抗拒”之原因造成的,因为旧版本的 ON_WM_NCHITTEST 宏使用了
UINT (__thiscall CWzButton::* )(CPoint);
类型的类成员函数指针,其定义如下:
#define ON_WM_NCHITTEST() \
{ WM_NCHITTEST, 0, 0, 0, AfxSig_wp, \
(AFX_PMSG)(AFX_PMSGW)(UINT (AFX_MSG_CALL CWnd::*)(CPoint))&OnNcHitTest },
但是新版本变成了:
#define ON_WM_NCHITTEST() \
{ WM_NCHITTEST, 0, 0, 0, AfxSig_l_p, \
(AFX_PMSG)(AFX_PMSGW) \
(static_cast< LRESULT (AFX_MSG_CALL CWnd::*)(CPoint) > (&ThisClass :: OnNcHitTest)) },
UINT (__thiscall CWzButton::* )(CPoint);
修改的方法就是将你的OnNcHitTest函数由:
afx_msg UINT OnNcHitTest(CPoint point);
改成:
afx_msg LRESULT OnNcHitTest(CPoint point);
======================================================================本文 End==
这个程序是用在大文件下多线程CRC32的校验。
VC6版本的链接
VC8版本的链接
分享到:
相关推荐
由VC6.0开发的工程项目,移植到VS2010环境下,会出现各种错误和警告,此类错误多数是由编译器和环境不兼容导致,除修改工程下的某些属性参数外,还需手动修改编译过程中出现的一些错误。
130个加密解密的源码,基于VC的工程,有VS2005版本和VC6版本的,可以参考下里面的函数实现
一款使用VC6.0或VS2005-2012开发必备的工具Visual assist x(破解版)。永久破解。不反弹,哈哈。本人就是使用这个
opencv-3.4.6-vc14_vc15.zip---官方OpenCV安装包,可配合PaddleInference推理库部署Paddle模型使用
本文档主要是给出了工程在迁移过程中由于开发环境不同所导致的的一些错误,并给出解决方案
VC6从入门到精通-基础篇(WDL格试).rar VC6从入门到精通-基础篇(WDL格试).rar
VC6从入门到精通-开发者眼中的VC
VC6从入门到精通-VC与数据库管理
vc2008到vc2017, vc9到vc15, 32位和64位全有, vc13(2014) 没有找到, vc库打包下载!!!
VC6从入门到精通-基础篇,原版通用教材。
首先说一下版本对照:Visual c++ 6.0(单独的C++编译器),VC----7.0(微软第一次把VC嵌入到Visual Studio .net),VC2003----VC7.1,VC2005----VC8.0,VC2008----9.0,因为.net框架是基于项目的,所以C++程序在VC...
vc运行时库(2005、2008、2010,含x86、x64)
VC6从入门到精通-VC与数据库管理 里面有一些关于VC和数据库的知识
图像匹配 opencv-2.4.13.6-vc14.exe和opencv-4.1.0-vc14_vc15.exe
opencv-3.4.0-vc14_vc15---.rar
解决所有装系统软件时遇到的缺少vc运行库2005-2010的问题,
vc2008到vc2017, vc9到vc15, 32位和64位全有, vc13(2014) 没有找到, vc库百度网盘打包下载!!!
php-5.3.5-Win32-VC6-x86.zip是官方提供的PHP-5.3最后一个x86-vc6-ts的版本