Main Content

Code replacement library

Library that defines code optimizations for specific target environment

Model Configuration Pane: Code Generation / Interface


The Code replacement library parameter specifies a code replacement library that the code generator uses when producing code for a model. A code replacement library defines code optimizations for a specific target environment.


  • To enable this parameter, set System target file to a GRT-based system target file.

  • To enable parameter Code replacement libraries (Embedded Coder), set System target file to an ERT-based system target file.


None (default) | named code replacement libraries

Does not use a code replacement library.

Named code replacement libraries

Generates calls to a code replacement library for a specific platform, compiler, or standard. The list of named libraries depends on the specified system target file.


  • Before setting this parameter, verify that your compiler supports the library that you want to use. If you select a parameter value that your compiler does not support, compiler errors can occur.

  • If you set parameter Shared code placement to Shared location or you generate code for models in a model reference hierarchy:

    • Models that are sharing the location or are in the model hierarchy must specify the same code replacement library (same name, tables, and table entries).

    • If you change the name or contents of the code replacement library and rebuild the model from the same folder as the previous build, the code generator reports a checksum warning (see Manage the Shared Utility Code Checksum (Embedded Coder)). The warning prompts you to remove the existing folder and stop or stop code generation.

  • If both of the following conditions exist for a model that contains Stateflow® charts, the code generator reproduces code for the charts and recompiles the generated code.

    • You do not set parameter Shared code placement to Shared location.

    • You change the code replacement library name or contents before regenerating code.

Recommended Settings

DebuggingNo impact
TraceabilityNo impact
EfficiencyValid library
Safety precautionNo impact

Programmatic Use

Parameter: CodeReplacementLibrary
Type: character vector
Value: 'None' | 'GNU C99 extensions'
Default: 'None'

Version History

Introduced in R2012a