| Embedded MATLAB™ | ![]() |
| On this page… |
|---|
About the C-MEX Compiler Configuration Object |
Embedded MATLAB MEX provides a configuration object emlcoder.CompilerOptions for fine-tuning C-MEX compilation.
To set C-MEX compilation options, follow these steps:
Define the compiler configuration object in the MATLAB workspace by issuing a constructor command, like this:
comp_cfg = emlcoder.CompilerOptions
Modify the compilation options as necessary, either at the command line or using a dialog box.
Invoke emlmex with the -s option and specify the configuration object as its argument, as in this example:
emlmex -s comp_cfg myMfile
The -s option instructs emlmex to convert myFile.m to a C-MEX function, based on the compilation settings in comp_cfg.
There are two ways to modify compilation options for emlmex:
You can use dot notation to modify the value of one compilation option at a time, using this syntax:
configuration_object.property = value
Dot notation uses assignment statements to modify configuration object properties. For example, to change the maximum size function to inline and the stack size limit for inlined functions during C-MEX generation, enter this code at the command line:
co_cfg = emlcoder.CompilerOptions co_cfg.InlineThreshold = 25; co_cfg.InlineStackLimit = 4096; emlmex -s co_cfg myFun
Besides using commands, you can modify compilation options using dialog boxes, as described in Compiler Options Dialog Box.
emlmex resolves options from left to right, so if you use conflicting options, the rightmost one prevails. For example, assume you define a compilation configuration object as follows:
co_cfg = emlcoder.CompilerOptions co_cfg.InlineThreshold = 20; co_cfg.InlineThresholdMax = 100; co_cfg.InlineStackLimit = 5000;
What happens when you execute the following command?
emlmex -s co_cfg -O disable:inline myFun
None of your inlining options take effect because the -O option overrides the -s option to disable inlining.
![]() | Making M-Code Compliant with the Embedded MATLAB Subset | Specifying Properties of Primary Function Inputs | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |