Error using mex : In function 'void mexFunction(int, mxArray**, int, const mxArray**)'
3 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(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 个评论
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!