convert from void (__thiscall Phone::* )(pjsua_acc_id) to void (__cdecl *)(pjsua_acc)

Discussion in 'C Programming' started by ahong, Apr 2, 2009.

  1. ahong

    ahong

    Joined:
    Apr 2, 2009
    Messages:
    2
    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:
    ahong, Apr 2, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sydex
    Replies:
    12
    Views:
    6,452
    Victor Bazarov
    Feb 17, 2005
  2. Polanski24
    Replies:
    1
    Views:
    531
    Rolf Magnus
    Apr 11, 2005
  3. sharmadeep1980@gmail.com
    Replies:
    1
    Views:
    1,621
    Murali Krishna
    Jul 7, 2006
  4. 2005
    Replies:
    2
    Views:
    436
    Salt_Peter
    Oct 25, 2006
  5. Rene Ivon Shamberger

    convert Phone Letters to Phone numbers

    Rene Ivon Shamberger, Dec 4, 2012, in forum: C++
    Replies:
    5
    Views:
    361
Loading...

Share This Page