-
October 21st, 2010, 08:06 AM
#1
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
-
October 21st, 2010, 02:06 PM
#2
Re: cannot convert parameter 1 from 'int (__stdcall CAdoreDemoEventSink::* )(int,int)
Originally Posted by rohitnegi
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
-
October 23rd, 2010, 02:52 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|