I have the following problem with compiling a C ++ file from a third-party library in mex using the Visual C ++ 2010 compiler (cl.exe).
The compiler complains about several lines in the following expression:
plhs[i] = mxCreateNumericMatrix(nclass, 1, mxDOUBLE_CLASS, 0);
with:
error C2664: 'mxCreateNumericMatrix_730': cannot convert parameter 4 from 'int' to 'MxComplexity'
the reason is that mxCreateNumericMatrix accepts an enum type as input argument 4 , called mxComplexity , which is defined as typedef enum mxComplexity {mxREAL=0, mxCOMPLEX}; . In other words, the compiler complains that it cannot implicitly convert from int to an enumeration type.
Interestingly, however, the library in question should be easy to compile without having to change anything in it.
So my question is: instead of adding an explicit cast to every line where this happens, is there a way to tell mex , cl.exe (or gcc if I did this on Unix) that I want to use an implicit C-style type conversion?
Note 1: Unfortunately, I do not know in which C ++ standard the library was written.
Note 2: In case this matters, this is the configuration that I have for mex (which is configured by default MATLAB, after running mex -setup ):
CompilerExecutable: 'cl' CompilerFlags: '/c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD' OptimizationFlags: '/O2 /Oy- /DNDEBUG' DebugFlags: '/Z7' LinkerExecutable: 'link' LinkerFlags: '/dll /export:%ENTRYPOINT% /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"%LIB_NAME%.x" /MAP:"%OUTDIR%%MEX_NAME%%MEX_EXT%.map"' LinkerOptimizationFlags: '' LinkerDebugFlags: '/debug /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"'