help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A question about the declaration of mxCreateStructArray in mex.


From: Aquil H. Abdullah
Subject: A question about the declaration of mxCreateStructArray in mex.
Date: Thu, 19 Jul 2007 15:27:09 -0400

First let me  say that I know that Octave is not Matlab so this post is mostly for clarity, (Although

Matlab declares the function mxCreateStructArray as follows:

mxArray *mxCreateStructArray(mwSize ndim, const mwSize *dims, int nfields,
                                               const char **fieldnames);

Octave defines the function mxCreateStructArray as follows:

mxArray *
mxCreateStructArray (int ndims, int *dims, int num_keys, const char **keys)
{
  return maybe_mark_array (new mxArray (ndims, dims, num_keys, keys));
}

While compiling a bit of mex code for use with octave I ran into the following error:

Utils.cpp:38: error: invalid conversion from `const int*' to `int*'
Utils.cpp:38: error:   initializing argument 2 of `mxArray* mxCreateStructArray(int, int*, int, const char**)'

To fix this I used a conditionally compiled the code that I was working on:

#ifdef USE_OCTAVE
  mxArray * v = mxCreateStructArray(ndims, const_cast <int *>(dims), nFields, fields);
#else
  mxArray * v = mxCreateStructArray(ndims, dims, nFields, fields);
#endif

Since a call to mxCreateStructArray eventually winds up in mxArray, which supplies a the constructor:

mxArray (int ndims, const int *dims, int num_keys, const char **keys);

I was wondering if there was a particular reason that mxCreateStructArray was implemented in its current fashion?

Thanks!

--
Aquil H. Abdullah
address@hidden
reply via email to

[Prev in Thread] Current Thread [Next in Thread]