Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

Usage of function pointers

$
0
0
i am tryting to call the callback function as described in SetRcvHandler() function inside a class CAppAIUInterface. it is giving an error

a value of type "int (CAppAIUInterface::*)(unsigned long pMessage)" cannot be used to initialize an entity of type "int (*)(unsigned long)"


Code:

int CAIUInterface::SetRcvHandler(unsigned char &pChNo, void (*pHandler)(unsigned long pMessage))
{
        if(pHandler != NULL)
        {
                if(pChNo == CHANNEL_1)
                       
                        m_fnRx1Handler = pHandler;
                else if(pChNo == CHANNEL_2)
                        m_fnRx2Handler = pHandler;
        }
        else
                return ERR_AIU_INVALID_HLR;

        return CPDS_SUCCESS;

}

/// m_fnRx1Handler  is a pointer and defined as following
void (*m_fnRx1Handler)(unsigned long pData);



short CAppAIUInterface::Initialise(short &DiscreteLine)
{
        int siResult = 0;
        u8Channel = CHANNEL_1;
        SetRcvHandler(u8Channel, (std::bind(CallBackRcv1Msg)));


Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images