Main Content

Set Up C Compiler and Compilation Options

Set Up C Compiler

Fixed-Point Designer™ automatically locates and uses a supported installed compiler. For the current list of supported compilers, see Supported and Compatible Compilers.

You can use mex -setup to change the default compiler. See Change Default Compiler.

C Code Compiler Configuration Object

For C code generation to a MEX file, MATLAB® provides a configuration object coder.mexconfig for fine-tuning the compilation. To set MEX compilation options:

  1. Define the compiler configuration object in the MATLAB workspace by issuing a constructor command:

    comp_cfg = coder.mexconfig
    MATLAB displays the list of compiler options and their current values in the command window.

  2. Modify the compilation options as necessary. See Compilation Options Modification at the Command Line Using Dot Notation

  3. Invoke fiaccel with the -config option and specify the configuration object as its argument:

    fiaccel -config comp_cfg myMfile

    The -config option instructs fiaccel to convert myFile.m to a MEX function, based on the compilation settings in comp_cfg.

Compilation Options Modification at the Command Line Using Dot Notation

Use dot notation to modify the value of compilation options, 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 MEX generation, enter this code at the command line:

co_cfg = coder.mexconfig
co_cfg.InlineThreshold = 25;
co_cfg.InlineStackLimit = 4096;
fiaccel -config co_cfg myFun

How fiaccel Resolves Conflicting Options

fiaccel takes the union of all options, including those specified using configuration objects, so that you can specify options in any order.