Mex error: "error C2664: 'mxCreateN​umericArra​y_730' : cannot convert parameter 2 from 'int [2]' to 'const size_t *'"?

6 次查看(过去 30 天)
the code is look like this
mxArray *mxconf = NULL;
mxconf = mxCreateNumericArray(2, maps_dim, mxSINGLE_CLASS, mxREAL);

采纳的回答

James Tursa
James Tursa 2017-7-22
The signature for mxCreateNumericArray is:
mxArray *mxCreateNumericArray(mwSize ndim, const mwSize *dims,
mxClassID classid, mxComplexity ComplexFlag);
The macro mwSize evaluates to a specific type at compile time depending on the current settings. For your case and from the error message, this appears to be size_t. So the effective signature for your particular case is:
mxArray *mxCreateNumericArray(size_t ndim, const size_t *dims,
mxClassID classid, mxComplexity ComplexFlag);
And, from the error message, it appears you have maps_dim as an array of int. I.e., you have something like this in your code:
int maps_dim[2];
An int is a signed integer, probably 4 bytes on your system. A size_t is an unsigned integer, possibly 8 bytes on your system. You can't convert a pointer_to_int into a pointer_to_size_t because the underlying types are different. You need to make sure all of the pointer arguments in these function calls are exactly the same. So change your definition of maps_dim:
mwSize maps_dim[2];
Then that 2nd argument will match.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by