Error using mex : In function 'void mexFunction(int, mxArray**, int, const mxArray**)'
显示 更早的评论
In my mecherMex.cpp, I wright down "void mexFunction (int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) {", but I dont know why system says my function is 'void mexFunction(int, mxArray**, int, const mxArray**)'. Does any one has same problem?
回答(1 个)
James Tursa
2020-6-8
编辑:James Tursa
2020-6-8
The error is not with mexFunction. The error is with line in your source code:
const int32_t *dims1 = mxGetDimensions(prhs[1]);
which needs to be this instead:
const mwSize *dims1 = mxGetDimensions(prhs[1]);
To answer your question as to why you write this signature:
void mexFunction (int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
but the compiler says the signature is this:
void mexFunction(int, mxArray**, int, const mxArray**)
you have to remember that C/C++ does not pass arrays in argument lists. The square brackets [ ] that look like arrays are in fact interpreted by the compiler as "pointer to" when they appear in argument lists. So this
mxArray *plhs[ ]
in an argument list does not mean "array of pointers to mxArray"
It does mean "pointer to pointer to mxArray", i.e. the [ ] simply gets replaced with "pointer to".
2 个评论
CHENGXIAN KI
2020-6-10
James Tursa
2020-6-10
Looks to me like you still have mwSize vs int32_t mismatches in your code. You need to fix those up.
类别
在 帮助中心 和 File 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!
