MATLAB: MexCallMATLAB, why no const 4th argument

mex

This simple mex program
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mexCallMATLAB(0, NULL, 1, &prhs[0], "disp");
}
gives an annoying compiler warning:
testmexcallmatlab.c: In function ‘mexFunction’: testmexcallmatlab.c:5:3: warning: passing argument 4 of ‘mexCallMATLAB’ from incompatible pointer type [enabled by default] /usr/local/matlab/r2011a/extern/include/mex.h:250:12: note: expected ‘struct mxArray ’ but argument is of type ‘const struct mxArray ’
Otherwise the program of course works, but why is in mex.h the 4th argument of mexCallMATLAB declared as "mxArray *prhs[]" rather than "const mxArray *prhs[]", Matlab functions are not supposed to change the righthand side arguments?

Best Answer

Good question. I assume, the input of mexCallMATLAB is usually defined inside the Mex and therefore not defined as const.
At least the standard settings of the MSVC compilers do not show a warning for your code.
Related Question