Main Content

Model Configuration Parameters: Code Style

TheCode Generation>Code Stylecategory includes parameters for configuring the appearance of the generated code. These parameters require a金宝app®Coder™license. Additional parameters for an ERT-based target require an Embedded Coder®license.

You can change the code style, cast expressions, and indentation of your generated code to conform to certain coding standards.

Code style modifications have the following uses:

  • Enhance the readability and traceability of code

  • Convey information across files

  • Enhance the efficiency of the generated code

  • Allow memory manipulation through type casting

On the Configuration Parameters dialog box, the following configuration parameters are on theCode Generation>Code Stylepane.

Parameter Description

Parentheses level

Specify parenthesization style for generated code.

总统erve operand order in expression

Specify whether to preserve order of operands in expressions.

总统erve condition expression in if statement

Specify whether to preserve empty primary condition expressions inifstatements.

Convert if-elseif-else patterns to switch-case statements

Specify whether to generate code forif-elseif-elsedecision logic as切换实例statements.

总统erve extern keyword in function declarations

Specify whether to include theexternkeyword in function declarations in the generated code.

总统erve static keyword in function declarations

Specify whether to include thestatickeyword in function declarations in the generated code.

Suppress generation of default cases for Stateflow switch statements if unreachable

Specify whether to generate default cases for switch-case statements in the code for Stateflow®charts.

Replace multiplications by powers of two with signed bitwise shifts

Specify whether to replace multiplications by powers of two with signed bitwise shifts.

Allow right shifts on signed integers

Specify whether to allow signed right bitwise shifts in the generated C/C++ code.

铸造模式

Specify how the code generator casts data types for variables.

Array container type

Specify the container type for arrays in the generated code. Choose either C-style array orstd::array.

Indent style

Specify style for the placement of braces in generated code.

Indent size

Specify indent size for generated code.

Newline style

Specify the newline style for generated code.

Maximum line width

Specify the maximum line width for wrapping the generated code.

Related Topics