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 = false;

  /* Disable interrupts here */

  /* Check for overrun */
  if (OverrunFlag) {
    rtmSetErrorStatus(rtM, "Overrun");
    return;
  }

  OverrunFlag = true;

  /* Save FPU context here (if necessary) */
  /* Re-enable timer or interrupt here */
  /* Set model inputs here */

  /* Step the model */
  CounterModel_step();

  /* Get model outputs here */

  /* Indicate task complete */
  OverrunFlag = false;

  /* Disable interrupts here */
  /* Restore FPU context here (if necessary) */
  /* Enable interrupts here */
}

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

void rt_OneStep(void)
{
  static boolean_T OverrunFlag = false;

  /* Disable interrupts here */

  /* Check for overrun */
  if (OverrunFlag)
  {
    rtmSetErrorStatus(rtM, "Overrun");
    return;
  }

  OverrunFlag = true;

  /* Save FPU context here (if necessary) */
  /* Re-enable timer or interrupt here */
  /* Set model inputs here */

  /* Step the model */
  CounterModel_step();

  /* Get model outputs here */

  /* Indicate task complete */
  OverrunFlag = false;

  /* Disable interrupts here */
  /* Restore FPU context here (if necessary) */
  /* Enable interrupts here */
}

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