I am pointing the member function of a class to the callbacks of a library function . It gives the following error
“cannot convert from 'void (__thiscall Phone::* )(pjsua_acc_id)' to 'void (__cdecl *)(pjsua_acc_id)' There is no context in which this conversion is possible”
Following is the coding in my program
/*********** Phone.h************/
#include <pjsua-lib/pjsua.h>
Phone:: public CDialog
{
…
void on_reg_state(pjsua_acc_id acc_id);
….
}
/************ Phone.cpp ***********/
#include "Phone.h"
void Phone:: on_reg_state(pjsua_acc_id acc_id)
{
pjsua_acc_info info;
CString reg_status;
pjsua_acc_get_info(acc_id,&info);
reg_status=info.status_text.ptr;
/** Now update the registration status on Phone’s main dialog, m_userinfo is the edit control value variable on Phone’s main dialog ******/
m_userinfo=reg_status;
UpdateData(false);
}
BOOL Phone:: OnInitDialog()
{
…………………………………………
pjsua_config cfg; //pjsua_config is a struct
……………………………………
cfg.cb.on_reg_state = &Phone:: on_reg_state;
---------------------------
…………………………………………….
}
/*********** pjsua.h**********/
typedef struct pjsua_config
{
…………..
pjsua_callback cb;
…………….
}
typedef struct pjsua_callback
{
……………………………………………….
void (*on_reg_state)(pjsua_acc_id acc_id);
……………………………………………………
}
if I declare the on_reg_state as a static function, the UpdateData(false) gives error as it cannot access the members of the class Phone. And if I dont call the "UpdateData(false)", the message is not updated.
I am badly stuck in this, please help :hmm2:
“cannot convert from 'void (__thiscall Phone::* )(pjsua_acc_id)' to 'void (__cdecl *)(pjsua_acc_id)' There is no context in which this conversion is possible”
Following is the coding in my program
/*********** Phone.h************/
#include <pjsua-lib/pjsua.h>
Phone:: public CDialog
{
…
void on_reg_state(pjsua_acc_id acc_id);
….
}
/************ Phone.cpp ***********/
#include "Phone.h"
void Phone:: on_reg_state(pjsua_acc_id acc_id)
{
pjsua_acc_info info;
CString reg_status;
pjsua_acc_get_info(acc_id,&info);
reg_status=info.status_text.ptr;
/** Now update the registration status on Phone’s main dialog, m_userinfo is the edit control value variable on Phone’s main dialog ******/
m_userinfo=reg_status;
UpdateData(false);
}
BOOL Phone:: OnInitDialog()
{
…………………………………………
pjsua_config cfg; //pjsua_config is a struct
……………………………………
cfg.cb.on_reg_state = &Phone:: on_reg_state;
---------------------------
…………………………………………….
}
/*********** pjsua.h**********/
typedef struct pjsua_config
{
…………..
pjsua_callback cb;
…………….
}
typedef struct pjsua_callback
{
……………………………………………….
void (*on_reg_state)(pjsua_acc_id acc_id);
……………………………………………………
}
if I declare the on_reg_state as a static function, the UpdateData(false) gives error as it cannot access the members of the class Phone. And if I dont call the "UpdateData(false)", the message is not updated.
I am badly stuck in this, please help :hmm2: