函数申明是这样的:
int Start(char *pchSmgIp, int nSmgPort, char *pchUserName, \
char *pchUserPwd, unsigned char uchVersion, int nActivtestInterval, \
void (*OnSmgMsg)(CMPP_SMGTOSP  css), int nConnType, \
void (*OnLogFile)(LPCTSTR pchFmt, ...) = NULL);void OnSmgMsg(CMPP_SMGTOSP css);
然后如下使用的时候,编译老是报c2664的错误,为什么啊?
nRetCode = cmpp.Start("1",1 , "1", "1",1 ,1 , OnSmgMsg,1,);

解决方案 »

  1.   

    void (*OnSmgMsg)(CMPP_SMGTOSP  css), int nConnType, \
    ...
    void OnSmgMsg(CMPP_SMGTOSP css);
    ???
      

  2.   

    CMPP_SMGTOSP怎么定义的?nRetCode = cmpp.Start("1",1 , "1", "1",1 ,1 , OnSmgMsg,1,);---》nRetCode = cmpp.Start("1",1 , "1", "1",1 ,1 , OnSmgMsg,1);
      

  3.   

    nRetCode = cmpp.Start("1",1 , "1", "1",1 ,1 , OnSmgMsg,1,"");
    CMPP_SMGTOSP 是一个结构体。
      

  4.   

    没有你全部的代码,不太好说,给你MSDN上对这一错误的解释,希望对你有所帮助编译器错误 C2664“function”: 不能将参数 number 从“type1”转换为“type2”某参数无法转换为所需类型。如果创建某个类的实例,然后试图对用 explicit 关键字标记的构造函数进行隐式转换,则可能发生此错误。如果将临时对象传递给采用指向对象的引用作为参数的函数,则该引用必须是常数引用。如果使用不是函数所预期的类型的参数调用该函数,则使用适当的构造函数创建临时对象。然后将该临时对象传递给函数。在这种情况下,该临时对象用于初始化引用。在该语言的早期版本中,所有的引用都可以由临时对象进行初始化。此行为现在已被逐步淘汰,因此 Microsoft C/C++ 编译器给出该错误。下面的代码通过调用带有字符串的 Test 演示此错误。因为该参数是 szString 引用,所以必须使用适当的构造函数创建对象。结果是一个无法用于初始化该引用的临时对象。示例 1// C2664a.cpp
    class A {} a;
    func( int, A );
    int main()
    {
       func( 1, 1 );  // C2664, no conversion from int to A
    }
    示例 2// C2664b.cpp
    #include <iostream.h>
    #include <string.h>class szString
    {
       int slen;
       char *str;public:
       szString(const char *);
       int len() const { return slen; }
    };void Test(szString &a) { cout << a.len();}szString::szString(const char * newstr)
    {
       slen=strlen(newstr);
       str = new char[slen + 1];
       strcpy(str, newstr);
    }int main()
    {
       Test("hello");   // C2664 expected
    }
    可能的解决方案 再次检查给定函数的原型,并改正错误信息中指出的参数。 
    如果需要的话,提供显式转换。
      

  5.   

    错误如下:
    error C2664: 'Start' : cannot convert parameter 7 from 'void (struct cmpp_smgtosp)' to 'void (__cdecl *)(struct cmpp_smgtosp)'这种我该怎么转换呢?
      

  6.   

    Compiler Error C2664
    'function' : cannot convert parameter number from 'type1' to 'type2'The specified parameter of the specified function could not be converted to the required type. If you’ve encountered this error on code which compiled with an earlier version of Visual C++, please read Technote: Improved Conformance to ANSI C++ for more information.The following is an example of this error:class A {} a;
    func( int, A );
    void main()
    {
       func( 1, 1 );  // error, no conversion from int to A
    }TipsRecheck the prototype for the given function and correct the argument noted in the error message. If necessary, an explicit conversion may need to be supplied.
      

  7.   

    nRetCode = cmpp.Start("1",1 , "1", "1",1 ,1 , &OnSmgMsg,1);