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

조회 수: 5 (최근 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