Hauptinhalt

hisl_0063: Length of user-defined object names to improve MISRA C compliance

R2026b

Limit the length of user defined names

Usage: High-Integrity System Modeling

Guideline ID: hisl_0063

Prerequisite: hisl_0060: Configuration parameters that improve MISRA C compliance

Rules

To improve MISRA C:2012 and MISRA C:2023 compliance of generated code, use configuration parameter Maximum identifier length (MaxIdLength) to limit the length of user defined names.

Note

The default of Maximum identifier length is 31.

hisl_0063: Length of user-defined object names to improve MISRA C compliance
A

For Subsystem blocks with parameter Function name options set to User specified, limit the length of function names to be equal to or less than the value specified in Maximum identifier length.

Rationale

Length in the generated code can result in a MISRAC:2012 and MISRA C:2023 violation.

Verification

Check for length of user-defined object names (Simulink Check)

Example

You can limit the function name to the length equal to or less than the specified value using Code mappings. This can be used to avoid violation of MISRA rules.

Code mappings editor showing function name length

B

Limit the length of data object names to be equal to or less than the value specified in Maximum identifier length:

  • Simulink.AliasType

  • Simulink.NumericType

  • Simulink.VariantExpression

  • Simulink.Bus

  • Simulink.BusElement

  • Simulink.IntEnumType

Rationale

Length in the generated code can result in a MISRAC:2012 and MISRA C:2023 violation.

Verification

Check for length of user-defined object names (Simulink Check)

C

When using these storage classes, limit the length of signal and parameter names to be equal to or less than the value specified in Maximum identifier length:

  • Exported Global

  • Imported Extern

  • Imported Extern Pointer

  • Custom storage class

Note

If specified, this includes the length of the Identifier name.

Rationale

Length in the generated code can result in a MISRAC:2012 and MISRA C:2023 violation.

Verification

Check for length of user-defined object names (Simulink Check)

Tips

  • When using a service Interface configuration, identifiers derived from expansion tokens (e.g., $R, $X, etc.) can exceed the maximum identifier length.

Industry Standards

  • ISO 26262-6, Table 6 (1d) – No multiple use of variable names

  • DO-331, Section MB.6.3.2.e – 'Low-level requirements conform to standards'

    DO-331, MB.6.3.3.e 'Software architecture conforms to standards'

  • MISRA C:2012, Rule 5.1

    MISRA C:2012, Rule 5.2

    MISRA C:2012, Rule 5.3

    MISRA C:2012, Rule 5.4

    MISRA C:2012, Rule 5.5

  • MISRA C:2023, Rule 5.1

    MISRA C:2023, Rule 5.2

    MISRA C:2023, Rule 5.3

    MISRA C:2023, Rule 5.4

    MISRA C:2023, Rule 5.5

Version History

Introduced in R2011a

expand all