Error using mex : In function 'void mexFunction(int, mxArray**, int, const mxArray**)'
Mostra commenti meno recenti
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?
Risposte (1)
James Tursa
il 8 Giu 2020
Modificato: James Tursa
il 8 Giu 2020
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 Commenti
CHENGXIAN KI
il 10 Giu 2020
James Tursa
il 10 Giu 2020
Looks to me like you still have mwSize vs int32_t mismatches in your code. You need to fix those up.
Categorie
Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
