CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    74

    cannot convert parameter 1 from 'int (__stdcall CAdoreDemoEventSink::* )(int,int)'

    Hi all,
    I have the following function that is accessed from a dll in mfc based project and works fine .
    (in header file )
    int __stdcall Register(int CallId,int StatusCode);
    typedef int __stdcall fptr_regstate(int, int);
    typedef void (*RegState)(fptr_regstate cb);

    (in cpp file )
    RegState m_regstate;
    m_regstate = (RegState)GetProcAddress(hDLL,"onRegStateCallback");
    m_regstate(Register);

    and My problem is that i when i tried to use the above function in another application which is based on atl gives the error.
    (in header file )
    int __stdcall Register(int CallId,int StatusCode);
    typedef int __stdcall fptr_regstate(int, int);
    typedef void (*RegState)(fptr_regstate cb);

    (in cpp file )
    RegState m_regstate;
    m_regstate = (RegState)GetProcAddress(hDLL,"onRegStateCallback");
    m_regstate(&CAdoreDemoEventSink::Register);// this line gives the error

    I am gettting the following error:
    Error 3 error C2664: 'void (CAdoreDemoEventSink::fptr_regstate (__stdcall *))' : cannot convert parameter 1 from 'int (__stdcall CAdoreDemoEventSink::* )(int,int)' to 'CAdoreDemoEventSink::fptr_regstate (__stdcall *)'


    can anybody help me out of this.


    thanks ,
    rohit

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: cannot convert parameter 1 from 'int (__stdcall CAdoreDemoEventSink::* )(int,int)

    Quote Originally Posted by rohitnegi View Post
    Hi all,
    I have the following function that is accessed from a dll in mfc based project and works fine .
    (in header file )
    int __stdcall Register(int CallId,int StatusCode);
    typedef int __stdcall fptr_regstate(int, int);
    typedef void (*RegState)(fptr_regstate cb);

    (in cpp file )
    RegState m_regstate;
    m_regstate = (RegState)GetProcAddress(hDLL,"onRegStateCallback");
    m_regstate(Register);
    After 56 posts, you don't use code tags?

    Secondly, you are mixing non-class member functions with class member functions, or that is what it seems like, as you didn't post your full definitions.

    A pointer to a non-static member function is not the same as a pointer to function. They are two totally different things, but you're assigning one to the other.

    Either declare your class's RegisterFunction as static, or make it a global function.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Mar 2010
    Posts
    74

    Re: cannot convert parameter 1 from 'int (__stdcall CAdoreDemoEventSink::* )(int,int)

    yes ,after making the function static it works . thanks for the reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured