Hello all!
Quick question... How can I pass a Perl coderef to a C
library method which is expecting a function pointer
as a parameter?
Treating a typedef'ed function pointer as just another
type gives a segv. Well, it was very tempting to try!
A newbee approach:
// in the C library
typedef void (*myCallback) (int a);
void some_C_method(myCallback);
// in the Perl wrapper
void perl_method(SV* callback){
myCallback cb = (myCallback) SvIV(SvRV(callback));
some_C_method(cb);
}
# finally in Perl... as you've guessed already:
perl_method( sub{} );
Thanks!
Ogla
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com