Ask a Question related to Mac Programming, Design and Development.
-
Deyue Yu #1
why do I get an error message using template?
I'm using CW7.0 on the Mac. I got an error when I compiled the code
which copied from a windows C++ project. The following are related
subroutines. I can't send the whole one for it's too long.
Do you have any suggestion? Thanks!
Dion
___________________________________
Link error: undefined ‘_cut_fp2unsigned' (code)
Reference from ‘_get_numeric <UL> (const mxArray_tag*,
unsigned long*)' in square_mexFunction.cp
___________________________________
//square_mexFunction.cp
………………..
………………..
// Load up an array (which may consist only of a single element) with
// the values from a matlab object. Arguments:
// 1) The matlab object.
// 2) Where to put the values. The array should be allocated
sufficiently
// large so that all of the values in the matlab object can be
converted.
// These functions return 0 on error, or 1 if the operation succeded.
//
template <class FLOAT>
static int
_get_numeric(const mxArray *mat, FLOAT *arr) // float or double.
{
int idx;
int n_elements = _arraylen(mat); // Get the length.
if (mxIsDouble(mat)) // Ordinary double precision matrix?
{
double *pr = mxGetPr(mat); // Point to vector of double precision
values.
for (idx = 0; idx < n_elements; ++idx) // Loop through all
elements.
*arr++ = (FLOAT)*pr++; // Convert and copy this element.
}
else // Don't know what this is.
return 0; // Type conversion error.
return 1; // No error.
}
…………………
…………………
void _wrap_GPCTR_Change_Parameter(int nlhs, mxArray **plhs, int nrhs,
const mxArray **prhs)
{
if (nlhs > 1 ||
nrhs != 4+1)
mexErrMsgTxt("Wrong number of arguments to function
GPCTR_Change_Parameter");
int _d[4] = { 1,1,1,1 };
int _vec_n = 0;
int _vidx;
int _vec_sz;
short *_arg_deviceNumber;
unsigned long *_arg_gpCounterNumber;
unsigned long *_arg_paramID;
unsigned long *_arg_paramValue;
short *_arg_retval;
int _vecstride_deviceNumber = 1;
int _vecstride_gpCounterNumber = 1;
int _vecstride_paramID = 1;
int _vecstride_paramValue = 1;
if (!_check_input_vectorize(prhs[1], &_vec_n, _d, 0,
&_vecstride_deviceNumber))
mexErrMsgTxt("Error in dimension of argument deviceNumber");
if (mxIsInt16(prhs[1]) || mxIsUint16(prhs[1]))
_arg_deviceNumber = (short *)mxGetData(prhs[1]);
else
{
_arg_deviceNumber = MEM_ALLOC(short *, _arraylen(prhs[1]), sizeof
(short));
if (!_get_numeric(prhs[1], _arg_deviceNumber))
mexErrMsgTxt("Expecting numeric matrix for argument
deviceNumber");
}
if (!_check_input_vectorize(prhs[2], &_vec_n, _d, 0,
&_vecstride_gpCounterNumber))
mexErrMsgTxt("Error in dimension of argument gpCounterNumber");
if (mxIsInt32(prhs[2]) || mxIsUint32(prhs[2]))
_arg_gpCounterNumber = (unsigned long *)mxGetData(prhs[2]);
else
{
_arg_gpCounterNumber = MEM_ALLOC(unsigned long *,
_arraylen(prhs[2]), sizeof (unsigned long));
if (!_get_numeric(prhs[2], _arg_gpCounterNumber))
mexErrMsgTxt("Expecting numeric matrix for argument
gpCounterNumber");
}
if (!_check_input_vectorize(prhs[3], &_vec_n, _d, 0,
&_vecstride_paramID))
mexErrMsgTxt("Error in dimension of argument paramID");
if (mxIsInt32(prhs[3]) || mxIsUint32(prhs[3]))
_arg_paramID = (unsigned long *)mxGetData(prhs[3]);
else
{
_arg_paramID = MEM_ALLOC(unsigned long *, _arraylen(prhs[3]),
sizeof (unsigned long));
if (!_get_numeric(prhs[3], _arg_paramID))
mexErrMsgTxt("Expecting numeric matrix for argument paramID");
}
if (!_check_input_vectorize(prhs[4], &_vec_n, _d, 0,
&_vecstride_paramValue))
mexErrMsgTxt("Error in dimension of argument paramValue");
if (mxIsInt32(prhs[4]) || mxIsUint32(prhs[4]))
_arg_paramValue = (unsigned long *)mxGetData(prhs[4]);
else
{
_arg_paramValue = MEM_ALLOC(unsigned long *, _arraylen(prhs[4]),
sizeof (unsigned long));
if (!_get_numeric(prhs[4], _arg_paramValue))
mexErrMsgTxt("Expecting numeric matrix for argument
paramValue");
}
{
int _ds[] = { _d[0] , _d[1] , _d[2] , _d[3] };
plhs[0] = mxCreateNumericArray(max((0 + _vec_n), 2), _ds,
mxDOUBLE_CLASS, mxREAL);
_arg_retval = MEM_ALLOC(short *, _arraylen(plhs[0]), sizeof
(short));
}
_vec_sz = _d[0]*_d[1]*_d[2]*_d[3];
for (_vidx = 0; _vidx < _vec_sz; ++_vidx) {
_arg_retval[_vidx] = (short)
GPCTR_Change_Parameter(_arg_deviceNumber[_vecstride_deviceNumber*_vidx],
_arg_gpCounterNumber[_vecstride_gpCounterNumber*_vidx],
_arg_paramID[_vecstride_paramID*_vidx],
_arg_paramValue[_vecstride_paramValue*_vidx]);
}
{
int _fidx;
double *d_ptr = mxGetPr(plhs[0]);
for (_fidx = 0; _fidx < _arraylen(plhs[0]); ++_fidx)
*d_ptr++ = (double)*_arg_retval++;
}
}
……………………
……………………
Deyue Yu Guest
-
How To Supress Acrobat Error Message And Alert Message
Is there any way to supress those pop up message? If can't, is there any way to catch it? -
Error Message When Sending Message In Windows Mail
Am I the only one getting an error message when replying to a posted message using Windows Mail. Every time I send a message I get a popup error... -
Template error code 3 + Error Accessing files..
Hi, I am really out of any idea after searching Macromedia website and still cant find the solution. I faced the error code 3 when trying to update... -
Template Error Message
hi, I am wondering if anyone can help me. Some else has designed the website that i am now in charge of updating and editing. i have made some... -
Error message when updating template
Hi...I've created a template that I use to update several pages on a website. When I make changes to the template...and save it, I'm asked if I want... -
MW Ron #2
Re: why do I get an error message using template?
In article <442f5600.0307020801.1e28840a@posting.google.com >,
[email]dionyue@msn.com[/email] (Deyue Yu) wrote:
>I'm using CW7.0 on the Mac. I got an error when I compiled the code
>which copied from a windows C++ project. The following are related
>subroutines. I can't send the whole one for it's too long.
>Do you have any suggestion? Thanks!Linker errors for undefined items, are where you don't have the function>___________________________________
>Link error: undefined ‘_cut_fp2unsigned' (code)
> Reference from ‘_get_numeric <UL> (const mxArray_tag*,
>unsigned long*)' in square_mexFunction.cp
>___________________________________
defined. For example if you have mxGetPr in a header file it will
compile but if you have this function in a C source file or forgot to
add that file to your project (or that library to the project) you will
get a linker undefined error.
Check to be sure you have the file in a C++ file. It is easy to have
force C++ enabled in one and not in another and get these type of
undefined linker errors.
Bottome line is that the actual code is missing or misnamed for _cut_
Ron
-->
>//square_mexFunction.cp
>………………..
>………………..
>// Load up an array (which may consist only of a single element) with
>// the values from a matlab object. Arguments:
>// 1) The matlab object.
>// 2) Where to put the values. The array should be allocated
>sufficiently
>// large so that all of the values in the matlab object can be
>converted.
>// These functions return 0 on error, or 1 if the operation succeded.
>//
>template <class FLOAT>
>static int
>_get_numeric(const mxArray *mat, FLOAT *arr) // float or double.
>{
> int idx;
> int n_elements = _arraylen(mat); // Get the length.
>
> if (mxIsDouble(mat)) // Ordinary double precision matrix?
> {
> double *pr = mxGetPr(mat); // Point to vector of double precision
>values.
>
> for (idx = 0; idx < n_elements; ++idx) // Loop through all
>elements.
> *arr++ = (FLOAT)*pr++; // Convert and copy this element.
> }
> else // Don't know what this is.
> return 0; // Type conversion error.
>
> return 1; // No error.
>}
Metrowerks has moved, our new address is now
7700 West Parmer Lane
Austin, TX 78729
Sales and Support 512-996-5300 800-377-5416
Ron Liechty - [email]MWRon@metrowerks.com[/email] - [url]http://www.metrowerks.com[/url]
MW Ron Guest



Reply With Quote

