【发布时间】:2014-04-04 19:23:20
【问题描述】:
有人可以帮我解决这个错误吗?我是 C++ 新手。而且似乎错误发生在一堆宏中。我能做些什么来解决它?或者我怎样才能找到它的源头?
我真的不明白这个错误。这是否意味着编译器试图将方法void ReadCPUparameter()转换为LRESULT funcName(WPARAM wParam, LPARAM lParam)函数头?
错误:
// error C2440: 'static_cast' : cannot convert from
// 'void (__thiscall CStartup::* )(void)' to
// 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'.
//
// ON_MESSAGE(WM_UPLOAD_CPU_PARAMETER,ReadCPUparameter) // error here
(这不是我写的。我需要在Win7机器上从Win2000重新编译一个旧项目。旧VS6.0项目-> VS2010 Prof.)
代码:
// class CStartup : public CDialog {};
#include "stdafx.h"
#include "MU.h"
#include "Startup.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CStartup::CStartup(CWnd* pParent /*=NULL*/) : CDialog(CStartup::IDD, pParent)
{
p_p = &cpu_par;
}
void CStartup::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CStartup, CDialog)
ON_WM_SHOWWINDOW()
ON_MESSAGE(WM_UPLOAD_CPU_PARAMETER,ReadCPUparameter) // error here
END_MESSAGE_MAP()
const int nLanguageIds_Language[] =
{
// ...
};
#define MAX_READINGS 200
BOOL CStartup::OnInitDialog()
{
// ...
}
void CStartup::OnOK()
{
CDialog::OnOK();
}
int CStartup::Check_OnRead()
{
// ...
}
void CStartup::ReadCPUparameter()
{
// ...
}
void CStartup::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
PostMessage( WM_UPLOAD_CPU_PARAMETER );
}
【问题讨论】:
-
我认为错误消息完全表明这是错误的。那么为什么不将函数签名修复为预期的签名。
-
@vlad_tepesch 你能指出我的意思吗?请阅读问题的第二段。我对 C++ 错误不太熟悉。