in reply to simple XS

I'm not surprised you get a segfault. I'm surprised you don't get a compiler warning. Isn't this a big problem?

int get(self,index) SV* self int index

A Perl integer is also an SV with the IV flag set. Unless you (somehow) have a typemap set up to convert your SvIV to a C integer, I think you're letting C coerce the address of the pointer to an integer and trying to use that as the array index. That's a one-way ticket to segfault town.

Replies are listed 'Best First'.
Re^2: simple XS
by ikegami (Patriarch) on Mar 01, 2010 at 12:37 UTC

    The typemap handles it.

    #!/usr/bin/perl use Inline C => <<'EOC'; void show(int index) { PerlIO_printf(PerlIO_stdout(), "%d\n", index); } EOC show(123456);
    123456

      Thanks for confirming. Clearly I need better typemaps!