Mex error: "error C2664: 'mxCreateNumericArray_730' : cannot convert parameter 2 from 'int [2]' to 'const size_t *'"?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
K M Ibrahim Khalilullah
le 14 Juil 2017
Réponse apportée : James Tursa
le 22 Juil 2017
the code is look like this
mxArray *mxconf = NULL;
mxconf = mxCreateNumericArray(2, maps_dim, mxSINGLE_CLASS, mxREAL);
0 commentaires
Réponse acceptée
James Tursa
le 22 Juil 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.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!