http://www.perlmonks.org?node_id=234367

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

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