|
Boost Users : |
From: Sohail Somani (s.somani_at_[hidden])
Date: 2007-05-08 15:21:10
> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Li,
> PingShan (Kansas City)
> Sent: Tuesday, May 08, 2007 7:44 AM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] boost::bind,C++ member function
> and C callback function
>
>
> Changing the OpenSSL API is not an option for me.
>
> Let's assume that the callback function accepts a void*
> parameter, can you show me an example that I
> can bind C++ member function to a C callback function?
Untested:
typedef boost::function<void(void)> fn_t;
void generic_c_callback(void * data)
{
fn_t * f(reinterpret_cast<fn_t *>(data));
if(f) (*f)();
else log_oops("...");
// delete f; ?
}
int main()
{
register_c_callback(generic_c_callback,new
fn_t(bind(a,something,something,something)));
}
I think something like this could work, but have never actually tried it
:-)
Sohail
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net