I'm trying to set a seemingly-simple callback method pointer into a variable and get the following error:
CSerialSniffer.cpp|11|error: cannot convert ‘CSerialSniffer::AsyncRecieverReceived’ from type ‘Nexus::TReceiveCallback (CSerialSniffer::)(Nexus::CData*, Nexus::IMetaData*)’}’| to type ‘Nexus::typeAsyncReceiverCallback {aka Nexus::TReceiveCallback ()(Nexus::CData, Nexus::IMetaData*)}’|
Here is the set statement:
typeAsyncReceiverCallback l_pPointer = AsyncRecieverReceived;
And I have the following defined:
typedef TReceiveCallback (*typeAsyncReceiverCallback)(CData *a_pData, IMetaData *a_pMetaData);
class CSerialSniffer
{
...
public:
Nexus::TReceiveCallback AsyncRecieverReceived(Nexus::CData *a_pData, Nexus::IMetaData *a_pMetaData);
...
}
I've been at this for hours now, any ideas?
In response to answers: I have the same callback mechanism here:
typedef void (*EnqueueCallback)( PData *pd );
class SomeClass
{
...
public:
void enqueue( PData *pd );
...
};
class CSerialSniffer
{
...
public:
void set_enqueue_callback(EnqueueCallback a_pEnqueueCallback );
...
}
SomeClass::SomeFunction(){
this->serialSniffer->set_enqueue_callback(this->enqueue);
}
And it compiles well. What's the difference between the two?