Main Content

Parentheses

Parenthesization level in the generated code

Description

App Configuration Pane: Code Appearance

Configuration Objects: coder.EmbeddedCodeConfig

Parenthesization level in the generated code.

Settings

Nominal (Optimize for readability)

This value is the default value.

The code generator inserts parentheses to balance readability and visual complexity. For example:

Out = ((In2 - In1 > 1.0) && (In2 > 2.0));

Maximum (Specify precedence with parentheses)

The code generator includes parentheses to specify meaning without relying on operator precedence. Code generated with this setting conforms to MISRA™ requirements. For example:

 Out = (((In2 - In1) > 1.0) && (In2 > 2.0));

Minimum (Rely on C/C++ operators for precedence)

The code generator inserts parentheses where required by ANSI® C or C++, or to override default precedence. For example:

Out = In2 - In1 > 1.0 && In2 > 2.0;

If you generate C/C++ code that uses the minimum level, for certain settings in some compilers, you can receive compiler warnings. To eliminate these warnings, try the nominal level.

Programmatic Use

Property: ParenthesesLevel
Values: 'Nominal' | 'Minimum' | 'Maximum'
Default: 'Nominal'

Version History

Introduced in R2011a