Main Content

Preserve static keyword in function declarations

Include static keyword in function declarations

Model Configuration Pane: Code Generation / Code Style

Description

Specify whether to include the static keyword in function declarations in the generated code.

Dependencies

  • This parameter requires Embedded Coder® license when you generate code.

  • This parameter appears only for ERT-based targets.

  • This parameter is enabled when you select Compact/Compact(with separate data file) file packaging.

Settings

on (default) | off

Default: on

On

Include the static keyword in function declarations in the generated code. You can link different executables generated from different models that refer to locally scoped subsystem and utility functions with the same name. This parameter also impacts these functions:

  • Stateflow® graphical function

  • Variant subsystem

  • MATLAB® subfunction

  • Simulink® function inside a subsystem

This parameter does not impact these functions:

  • Function in a model reference build

  • Simulink function at root level

When you select this parameter, the generated code is compliant with MISRA C:2012 Rule 8.10.

Off

Remove the static keyword in function declarations in the generated code.

Tips

  • If your function cannot use the static keyword because it requires external access, consider modeling it as a Simulink function at the root level.

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyOn (execution, ROM)
Safety precautionNo impact

Programmatic Use

Parameter: PreserveStaticInFcnDecls
Type: character vector
Value: 'on' | 'off'
Default: 'on'

Version History

Introduced in R2017b