Mex error: "error C2664: 'mxCreateNumericArray_730' : cannot convert parameter 2 from 'int [2]' to 'const size_t *'"?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
K M Ibrahim Khalilullah
am 14 Jul. 2017
Beantwortet: James Tursa
am 22 Jul. 2017
the code is look like this
mxArray *mxconf = NULL;
mxconf = mxCreateNumericArray(2, maps_dim, mxSINGLE_CLASS, mxREAL);
0 Kommentare
Akzeptierte Antwort
James Tursa
am 22 Jul. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!