None 3 个重载可以转换所有参数类型(在 MFC / C++ 项目中)

None of the 3 overloads could convert all the argument types (in MFC / C++ project)

我从我下载的另一个项目中复制了一些代码(并且编译正常),在我自己的项目中编译相同代码(一个名为 player.cpp 的文件)时收到编译器错误消息:

Error 1 error C2665: 'MATExceptions::MATExceptions' : none of the 3 overloads could convert all the argument types c:\users\daniel\documents\visual studio 2012\projects\mytest1\mytest1\player.cpp 137 1 Test1

错误发生在player.cpp这一行:

        EXCEP(DirectSoundErr::GetErrDesc(hres), _T("Player::CreateDS DirectSoundCreate"));

这里是 EXCEP 和 GetErrDesc 的定义:

#define EXCEP(/*const wchar_t * */ desc, /*const wchar_t * */ from) throw( MATExceptions(__LINE__,  _T(__FILE__), 0, from, desc) );

CComBSTR DirectSoundErr::GetErrDesc(HRESULT hres)
{
switch(hres)
{
    case DSERR_ALLOCATED : 
        return _T("The request failed because resources, such as a 
        priority level, were already in use by another caller.");               
...
    default : return _T("Unknown error");
}
}

我不知道有什么不同(因为我没有更改源文件player.cpp)。可能是因为我的项目中的编译器设置与原始项目相比不同(我该如何检查)?

我将 EXCEP 定义更改为以下内容:

#define EXCEP(desc, from) throw(MATExceptions(__LINE__, (wchar_t *)(__FILE__), 0, (wchar_t *)from, (wchar_t *)desc));

...并将调用从:

更改为
EXCEP(DirectSoundErr::GetErrDesc(hres), _T("Player::CreateDS DirectSoundCreate"));

至:

EXCEP(DirectSoundErr::GetErrDesc(hres), "Player::CreateDS DirectSoundCreate");

可以接受吗?

原来的 "new" 可以通过在项目中定义这些来杀死(我猜是从 Visual Studio 2015 年开始):

__PLACEMENT_NEW_INLINE __PLACEMENT_VEC_NEW_INLINE

但是一旦他们走了,他们就走了。现在您需要确保包含重新定义它们的特定于项目的头文件。