From your example it is not clear why are you using ST(2) in CODE section. In general, the declaration of function arguments tell xsubpp how to map perl variables into C variables. If you look at the generated by call "perl Makefile.PL" .c file, then you'll see how exactly the moving from perl variables to C variables shall happen.
You can affect this transition by providing initialization to your variables in the declaration. Then you don't need to provide CODE section. See for more details in perldoc perlxs.
One way to handle your situation could also be this. I don't know if this is what you want
foo * routine(a, b, c=NULL) SV * a SV * b SV * c INIT: ... if(!SvROK(c)) croak("Expected reference"); CODE: { SV * str = SvRV(c); }
Note. In your example you are using SvOK, I guess you want to use SvROK if you want to catch the reference.
In reply to Re: XS: How to enable passing ref or undef?
by andal
in thread XS: How to enable passing ref or undef?
by tlhackque
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |