Can I use boost::bind(mycallback, this, _1, _2) across C code?
Update
The short answer is no, boost bind does not return a function pointer, which can be called in C code, but a functor (C++ object with overloaded () operator) see answer below.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best way to do what you want to do is to create a C callback that then calls the boost::function, which is stored in some sort of user memory with new.
Example:
Then you simply pass this callback and set the user data(however it is specified in libev) to be a copy of your function allocated with new.
This is how you specify user data with libev:
http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#ASSOCIATING_CUSTOM_DATA_WITH_A_WATCH