If I define an Enumeration in MATLAB as
classdef testEnum < int32 enumeration Test0(0), ... Test1(1) endend
and pass an instance of that enumeration
temp.a = testEnum.Test1;mexEnum(temp)
to a C/C++ mex function, how do I access the integer value of the enumeration from within a C/C++ mex function?
For example compiling mexEnum.cpp with the code:
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { const int dims[2] = {1, 1}; plhs[0] = mxCreateNumericArray(2, dims, mxDOUBLE_CLASS, mxREAL); double *temp = (double*)mxGetData(plhs[0]); const mxArray *rhs = prhs[0]; mxArray *a = mxGetField(rhs, 0, "a"); int32_T *value = (int32_T *)mxGetData(a); double valueDouble = (double)(*value); *temp = valueDouble;}
does not return the value (1) I would expect.
Best Answer