User`s guide

5 Controlling Code Generation
5-20
VF Interface Function
The Compiler produces this interface function only when the M-function uses
the variable
nargout and has at least one output. The void interface function
specifies zero output arguments to the implementation version of the function,
and in the event that the implementation version still returns an output
(which, in MATLAB, would be assigned to the
ans variable), it deallocates the
output.
This is the corresponding
VF interface function (VFoo) for the foo.m example
described earlier in this chapter. This function calls the
Mfoo function
appearing in
foo.cpp:
//
// The function "Vfoo" contains the void interface for the
// "foo" M-function from file
// "<matlab>\extern\examples\compiler\foo.m" (lines 1-8).
// The void interface is only produced if the M-function
// uses the special variable "nargout", and has at least
// one output. The void interface function specifies zero
// output arguments to the implementation version of the
// function, and in the event that the implementation
// version still returns an output (which, in MATLAB, would
// be assigned to the "ans" variable), it deallocates the
// output. This function processes any input arguments and
// passes them to the implementation version of the
// function, appearing above.
//
void Vfoo(mwArray x, mwArray y) {
// ------------- Input Argument Processing ---------------
mwArray a = mwArray::UNDEFINED;
mwArray b = mwArray::UNDEFINED;
// ----------------- Call M-Function ---------------------
a = Mfoo(&b, 0, x, y);
}