I'm trying to make a c command for use in perl with perlxs. However there is an error in "make" and I can't seem to be able to fix it.

I'm makin command "do_pearson_matrix(\@in_table,$max_i,$max_j)", which should then return the new 2-d array. The $max_i and $max_j has information about the lenghts of my 2-d array (@in_table).

Error code:

$ make /usr/bin/perl -I/usr/lib/perl5/5.6.1/i386-linux -I/usr/lib/perl5/5.6.1 + /usr/lib/perl5/5.6.1/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.6.1/ +ExtUtils/typemap test_c.xs > test_c.xsc && mv test_c.xsc test_c.c gcc -c -fno-strict-aliasing -I/usr/local/include -O2 -march=i386 -mcp +u=i686 -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC -I/usr/lib/pe +rl5/5.6.1/i386-linux/CORE test_c.c test_c.xs: In function `XS_test_c_do_matrix': test_c.xs:19: subscripted value is neither array nor pointer test_c.xs:19: subscripted value is neither array nor pointer make: *** [test_c.o] Error 1

And the .xs file:

#include "EXTERN.h" #include "perl.h" #include "XSUB.h" MODULE = test_c PACKAGE = test_c double do_matrix (double &in_matrix,long max_i,long max_j,OUTLIST out_matrix[ +i][j]) PROTOTYPE: \@$$ CODE: long i,j,a; double value,out_matrix[i][j]; for (i=0;i<=max_i;i++) { for (j=(i-1);j>=0;j--) { value=0; for (a=0;a<=max_j;a++) { value=value+in_matrix[i][a]*in_matrix[j][a]; } value=value/max_j; out_matrix[i][j]=value; } }

So what am I doing wrong here. TIA


In reply to perlxs and gcc error by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.