Main Content

mclRunMain

Mechanism for creating identical wrapper code across all platforms

Synopsis

typedef int (*mclMainFcnType)(int, const char **);

int mclRunMain(mclMainFcnType run_main,
               int argc,
               const char **argv)

Description

As you need to provide wrapper code when creating an application which uses a C or C++ shared library created by MATLAB® Compiler SDK™, mclRunMain enables you with a mechanism for creating identical wrapper code across all MATLAB Compiler SDK platform environments.

mclRunMain is especially helpful in Macintosh OS X environments where a run loop must be created for correct MATLAB Runtime operation.

When a Mac OS X run loop is started, if mclInitializeApplication specifies the -nojvm or -nodisplay option, creating a run loop is a straightforward process. Otherwise, you must create a Cocoa framework. The Cocoa frameworks consist of libraries, APIs, and MATLAB Runtime that form the development layer for all of Mac OS X.

Generally, the function pointed to by run_main returns with a pointer (return value) to the code that invoked it. On Macintosh computers using Cocoa, when the run_main function finishes execution and returns a value, MATLAB Runtime exits immediately thereafter. This abrupt termination prevents the application from capturing the return value because the fundamental code loses its ability to control the shutdown process of Cocoa.

Caution

You should not use mclRunMain if your application brings up its own full graphical environment.

Note

In non-Macintosh environments, mclRunMain acts as a wrapper and does not perform any significant processing.

Parameters

run_main

Name of function to execute after MATLAB Runtime set-up code.

argc

Number of arguments being passed to run_main function. Usually, argc is received by application at its main function.

argv

Pointer to an array of character pointers. Usually, argv is received by application at its main function.

Examples

Call using this basic structure:

int returncode = 0;
mclInitializeApplication(NULL,0); 
returncode = mclRunMain((mclmainFcn)
                   my_main_function,0,NULL);

Version History

Introduced in R2010b