In XS, I can pass the length of the string argument to the C function with the keyword:
static int foo(const char *s, size_t len)
{
return 1;
}
MODULE = Foo PACKAGE = Foo
void
foo(char *s, STRLEN length(s))
However, how can I get the length of a string if I need it inside a CODE block?
void
foo(char *s, STRLEN length(s))
CODE:
...
foo(s, ???);
I can use the variable STRLEN_length_of_sor XSauto_length_of_s, auto-generated by xsubpp, but it's a bit hard-coded. Is there a way (possibly a predefined macro) that I can use to get the variable name? Or can I assign my name to the length argument? Or do I need to resort to declaring the argument as SV *, and then get the length of c SvPVin the CODE section?
source
share