On Thu, 23 Jul 2009, Erland Sommarskog wrote: > > "Jan Dubois" (j...@activestate.com) writes: > > This can happen with other magical SVs too. You must call SvGETMAGIC() > > before you can trust the SVf_?OK flags. SvIV() will do this as a side > > effect. > > Thus, in any place where I receive a value of which I don't know the > origin, I should call SvGETMAGIC first. I could then just as well > have > > BOOL sv_isdefined(SV *sv) { > SvGETMAGIC(sv); > return SvOK(sv); > } > > > Or would this lead in my new problems?
You should pass in the Perl context so it works under MULTIPLICITY (and by extension under USE_ITHREADS): #define sv_isdefined(sv) my_is_defined(aTHX_ sv) static BOOL my_sv_isdefined(pTHX_ SV *sv) { ... } Drop the "static" and move the #define into a header file if you need to call it from more than one source file. Cheers, -Jan