In my understanding, Perl functions have no analogous C function behind the scenes. Perl functions are called with the call_argv, call_method, call_pv, etc. APIs, which then go look up function names in the symbol tables, do some stack stuff, and execute some bytecode.
If you need to pass a function argument to some external function, you should probably use a wrapper. -Ken > -----Original Message----- > From: Ogla Sungutay [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 09, 2005 5:57 PM > To: inline@perl.org > Subject: CODEREF ----> typedef'ed function pointer > > > 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 >