Why do I obtain four overloaded functions when I attempt to compile my GUIDE created GUI into a C++ shared library using MATLAB Compiler 4.10 (R2009a)?

1 view (last 30 days)
I am attempting to create a shared library from a MATLAB GUI (myfig.m) using MATLAB Compiler 4.10 (R2009a). The GUI was created using GUIDE. It has variable number of input and output arguments.
When I create a C-shared library, I obtain the following function signatures for the MATLAB function "myfig":
bool MW_CALL_CONV mlxMyfig(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);
extern LIB_myfiglibc_C_API bool MW_CALL_CONV mlfMyfig(int nargout, mxArray** varargout, mxArray* varargin);
However, when I create a C++ shared library, I obtain an "mlx" function signature as above and four overloaded functions called "myfig" having the following signatures:
extern LIB_myfiglib_CPP_API void MW_CALL_CONV myfig(int nargout, mwArray& varargout, const mwArray& varargin);
extern LIB_myfiglib_CPP_API void MW_CALL_CONV myfig(int nargout, mwArray& varargout);
extern LIB_myfiglib_CPP_API void MW_CALL_CONV myfig(const mwArray& varargin);
extern LIB_myfiglib_CPP_API void MW_CALL_CONV myfig();
I am trying to understand these four overloaded functions generated when creating a C++ shared library as of what do each of these signatures represent. It would be better if this information is included in documentation.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
For releases >=R2010a:
This was fixed as of R2010a.
For releases < R2010a:
Documentation on the information about the overloaded functions generated while creating a C++ shared library is missing from MATLAB Compiler 4.10 (R2009a).
Here is the additional information about the different function signatures generated:
When creating a C++ shared library from a MATLAB function which has variable number of input and output arguments, four C++ function signatures are created for the MATLAB function. They are an exhaustive list of all possible ways the function can be called i.e.
a. with no input arguments and no output arguments - myfig();
b. multiple input arguments and no output arguments - myfig(const mwArray& varargin);
c. multiple output arguments and no input arguments - myfig(int nargout, mwArray& varargout);
d. multiple input and output arguments - myfig(int nargout, mwArray& varargout, const mwArray& varargin);
This allows you to call function in different ways depending upon the number of input arguments and output arguments.

More Answers (0)

Products


Release

R2009a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!