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

6 visualizzazioni (ultimi 30 giorni)
the code is look like this
mxArray *mxconf = NULL;
mxconf = mxCreateNumericArray(2, maps_dim, mxSINGLE_CLASS, mxREAL);

Risposta accettata

James Tursa
James Tursa il 22 Lug 2017
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.

Più risposte (0)

Categorie

Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by