I'm a beginner in XS and have spent some time looking for this answer on the web with no luck. The problem is that XS changes the name of the function and when it goes to compile, I will get an undefined reference error. For example consider the XS code below:
size_t
matrixIndex (colIndex, rowIndex,nCols,nRows)
size_t colIndex
size_t rowIndex
size_t nCols
size_t nRows
CODE:
size_t register i;
RETVAL = (rowIndex * nCols) + colIndex;
OUTPUT:
RETVAL
I then try to use this in the following function like this
int
matrixCopyColumnVector_dbl (colIndex,fromMatrix,nColsMatrix,nRowsMatrix,intoVector,nRowsVector)
size_t colIndex
SV * fromMatrix
size_t nColsMatrix
size_t nRowsMatrix
SV * intoVector
size_t nRowsVector
CODE:
size_t register x, n;
if( nRowsVector != nRowsMatrix) { RETVAL = 0; return RETVAL; }
n = 0;
for(x=0; x<= nRowsMatrix; x++) {
intoVector[n] = fromMatrix[matrixIndex /*USE OF FUNCTION HERE!!*/(colIndex,x,nColsMatrix,nRowsMatrix)];
n++;
}
RETVAL = 1;
return RETVAL;
OUTPUT:
RETVAL
I then run make
and it goes through the compile process and I get an error at what appears to be the linking stage of undefined reference to 'matrixIndex'
.
So I am wondering what is the standard XS way to call a function from within the same XS file?