Main Content

Indent style

Style for placement of braces

Model Configuration Pane: Code Generation / Code Style

Description

Specify style for the placement of braces in generated code.

Settings

K&R (default) | Allman

Default: K&R

K&R

For blocks within a function, an opening brace is on the same line as its control statement.

Allman

For blocks within a function, an opening brace is on its own line at the same level of indentation as its control statement.

Examples

expand all

Compare the array container types in the generated code when you set Indent style to different values.

Here is generated code that generated using the default Indent style value K&R:

void rt_OneStep(void)
{
  static boolean_T OverrunFlag = 0;
  if (OverrunFlag) {
    rtmSetErrorStatus(rtwdemo_counter_M, "Overrun");
    return;
  }

  OverrunFlag = TRUE;
  rtwdemo_counter_step();
  OverrunFlag = FALSE;
}

Here is the same code generated with Indent style set to Allman:

void rt_OneStep(void)
{
  static boolean_T OverrunFlag = 0;
  if (OverrunFlag)
  {
    rtmSetErrorStatus(rtwdemo_counter_M, "Overrun");
    return;
  }

  OverrunFlag = TRUE;
  rtwdemo_counter_step();
  OverrunFlag = FALSE;
}

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Programmatic Use

Parameter: IndentStyle
Type: character vector
Value: 'K&R' |'Allman'
Default: 'K&R'

Version History

Introduced in R2013b