呼叫参数太少

时间:2017-05-25 10:40:53

标签: c++ visual-c++ visual-studio-2012

所以基本上在其他编译器(visual studio 2003-2012)中这没关系,但是在visual studio 2013中却没有。可能有什么不对?错误正好在我的注释行中。

" theParameters"声明为:

#define theClass    CDPClient
#define theParameters   CAr & ar, DPID dpidUser, LPVOID lpBuffer, u_long uBufSize

void CDPClient::UserMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID idFrom )
{
    m_pDump = (BYTE*)lpMsg;
    m_nDumpSize = dwMsgSize;

    BYTE* pData = (BYTE*)lpMsg;
    for (DWORD i=0;i<dwMsgSize;i++)
    {
        pData[i] = pData[i] ^ ((BYTE)(i & 0xff) ^ 169);
        pData[i] = pData[i] ^ ((0xff - (BYTE)(i & 0xff)) ^ 86);
    }

    CAr ar((LPBYTE)lpMsg, dwMsgSize);
    GETTYPE( ar );

    void ( theClass::*pfn )( theParameters )    =   GetHandler( dw );

    if (pfn) {
        (this->*(pfn))(ar); // (ar) -> too few arguments for call. Why?
    }
    else{
        //g_DPCacheSrvr.Send( lpBuf, uBufSize, dpidUser );
    }

    m_pDump = NULL;
    m_nDumpSize = 0;
}

1 个答案:

答案 0 :(得分:2)

您有一个由{4}参数替换的宏theParameters。因此,调用需要4个参数,但您只提供一个ar

您可以阅读有关宏here的更多信息。标识符只是由定义的内容替换。所以在你的代码中,

void ( theClass::*pfn )( theParameters ) = GetHandler( dw );

变为

void ( theClass::*pfn )( CAr & ar, DPID dpidUser, LPVOID lpBuffer, u_long uBufSize ) = GetHandler( dw );

相关问题