Main Content

Avoid Identifier Name Collisions with Referenced Models

Within a model that uses referenced models, collisions between the names of the models are not allowed. When generating code from a model that uses model referencing:

  • You must include the $R token in the Identifier format control parameter specifications (in addition to the $M token).

  • The Maximum identifier length must be large enough to accommodate full expansions of the $R and $M tokens. If Maximum identifier length is too small, a code generation error occurs.

When a name conflict occurs between an identifier within the scope of a higher-level model and an identifier within the scope of a referenced model, the identifier from the referenced model is preserved. Name mangling is performed on the identifier from the higher-level model.

If your model contains two referenced models with the same input or output port names, and one of the referenced models contains an atomic subsystem with Function packaging set to Nonreuseable function, a name conflict can occur and the build process produces an error.

Use Model Advisor to Detect Identifier Names Changed During Code Generation

For a referenced model, if the following parameters on have specifications that do not contain a $R token (which represents the name of the reference model), code generation prepends the $R token to the identifier format.

You can use the Model Advisor to identify referenced models in a model referencing hierarchy for which code generation changes these configuration parameter settings.

  1. In the Modeling tab, click Model Advisor.

  2. Select By Task.

  3. Run the Check code generation identifier formats used for model reference check.

Related Topics