static int nu_get_userdatas(void *context ,
    int id, const char **result, unsigned *len)
{
   ......
}static int nu_get_usersecret(sasl_conn_t * conn ,
      void *context , int id,
      sasl_secret_t ** psecret)
{
   ......
}int init_sasl(nuauth_session_t * session, nuclient_error_t * err)
{
int ret;
sasl_conn_t *conn;
sasl_ssf_t extssf = 0; /* SASL time */ /*typedef int (*PROC)();
PROC proc=(PROC)&nu_get_userdatas; PROC proc2=(PROC)&nu_get_usersecret;
sasl_callback_t callbacks[] = {
{SASL_CB_USER, proc, session},
{SASL_CB_AUTHNAME,proc, session},
{SASL_CB_PASS, proc2, session},
{SASL_CB_LIST_END, NULL, NULL}
};
*/
sasl_callback_t callbacks[] = {
{SASL_CB_USER, &nu_get_userdatas, session},
{SASL_CB_AUTHNAME, &nu_get_userdatas, session},
{SASL_CB_PASS, &nu_get_usersecret, session},
{SASL_CB_LIST_END, NULL, NULL}
};
.......
}出错信息:error C2440: “初始化”: 无法从“int (__cdecl *)(void *,int,const char **,unsigned int *)”转换为“int (__cdecl *)(void)”       该转换要求 reinterpret_cast、C 样式转换或函数类型转换error C2440: “初始化”: 无法从“int (__cdecl *)(sasl_conn_t *,void *,int,sasl_secret_t **)”转换为“int (__cdecl *)(void)”
1>        该转换要求 reinterpret_cast、C 样式转换或函数类型转换运行环境:vs2005我改用c编译这个错误是不出现的.但是用C++方式是不行的.请高手解决.

解决方案 »

  1.   

    http://topic.csdn.net/u/20081102/17/57c0a1e7-7007-4190-a53a-816efd3c3c16.html
    分数不够再开贴
      

  2.   

    sasl.htypedef struct sasl_callback {
        /* Identifies the type of the callback function.
         * Mechanisms must ignore callbacks with id's they don't recognize.
         */
        unsigned long id;
        int (*proc)();   /* Callback function.  Types of arguments vary by 'id' */
        void *context;
    } sasl_callback_t;
      

  3.   


    //--------------- 一种方法 把下面两个函数重定义成 参数为void
    static int nu_get_userdatas(void *context ,
                    int id, const char **result, unsigned *len)
    {
       ......
    }static int nu_get_usersecret(sasl_conn_t * conn ,
                  void *context , int id,
                  sasl_secret_t ** psecret)
    {
       ......
    }
    //----------第二个方法强制转换
    sasl_callback_t callbacks[] = {
            {SASL_CB_USER, (int (*)())&nu_get_userdatas, session},
            {SASL_CB_AUTHNAME, (int (*)())&nu_get_userdatas, session},
            {SASL_CB_PASS, (int (*)())&nu_get_usersecret, session},
            {SASL_CB_LIST_END, NULL, NULL}
        };