[AGENT++] callback problem
Jochen Katz
katz at agentpp.com
Thu Jun 8 23:36:45 CEST 2006
Hi,
> *) In the header i did a typedef:
> typedef void (*snmp_callback)( int, Snmp*, Pdu&, SnmpTarget&, void*);
this is not needed, as uxsnmp.h already defines this.
> My compiler (g++ 3.4.5) says that
> snmpsession.cpp:187: error: no matching function for call to
> `Snmp::get(Pdu&, SnmpTarget&, <unresolved overloaded function type>, int)'
> void SNMPSession::getCallback(int reason, Snmp* session, Pdu &pdu,
> SnmpTarget &target, void* callback_data)
The problem is, that getcallback() has to be a plain C function (not
within a C++ class).
Below some code from the QtExample.
Rgards,
Jochen
/// C Callback function for snmp++
void callback(int reason, Snmp *snmp, Pdu &pdu, SnmpTarget &target,
void *cd)
{
if (cd)
{
// just call the real callback member function...
((MainWindow*)cd)->async_callback(reason, snmp, pdu, target);
}
}
// Now do an async get_next
status = snmp->get_next(pdu, *target, callback, this);
More information about the AGENTPP
mailing list