On Mon, Jun 14, 2004 at 04:04:18PM -0400, Roy Yves wrote: > Hi: Hello Roy, > > I am really puzzled with errors like the following: > > g++ -c pymat.cpp -o pymat.o -I/usr/local/matlab6p5/extern/include -I/usr/include/python2.2/numarray -I/usr/include/python2.2 > pymat.cpp: In function `mxArray* makeMxFromNumeric(const PyArrayObject*)': > pymat.cpp:216: invalid conversion from `const maybelong*' to `int*' > pymat.cpp:216: initializing argument 5 of `void copyNumeric2Mx(T*, int, int, > double*, int*) [with T = char]' > > where copyNumeric2Mx is a template function: > > template <class T> > void copyNumeric2Mx(T *pSrc, int pRows, int pCols, double *pDst, int *pStrides) > { // ... } > > for each instantiated template function like in the following: > case PyArray_CHAR: > copyNumeric2Mx((char *)(pSrc->data), lRows, lCols, lR, pSrc->strides); It seems pSrc->strides is a "pointer to const maybelong". Whatever kind of type `maybelong' may be, C++ forbids to assign a constant object (via a pointer) to a variable as this would allow to change the constant's value. Either declare copyNumeric2Mx like that: template <class T> void copyNumeric2Mx(T *, int, int, double*, const int*); ^^^^^ (in case you're allowed to change the function's prototype) OR you may "cast away" the object's constness: copyNumeric2Mx((char *)(pSrc->data), lRows, lCols, lR, const_cast<maybelong*>(pSrc->strides)); -- Claudio