代码样式
您可以配置代码生成器以遵循各种样式规则,使代码更具可读性和一致性。代码生成器可以删除或包含可选的语法功能,如括号和不可达语句。
您可以将代码生成器配置为以优先考虑性能或可读性的方式实现某些运算。例如,当乘以 2 的幂时,使用有符号按位移位运算符比使用乘法运算符更高效,但可读性较差。您可以将代码生成器配置为首选其中任一方法。
主题
- Enhance Readability of Code for Flow Charts
Describes how to convert if-elseif-else code to switch-case statements to enhance readability of generated code.
- Enhance Code Readability for MATLAB Function Blocks
Convert if-elseif-else code to switch-case statements.
- Improve Data Coherency in Generated Code
Generate a single unique variable for each Data Store read and write operation and thereby enhance Data Coherency.
- Control Parentheses in Generated Code
Specify how parentheses are placed in the code.
- Optimize Code by Reordering Commutable Operands
Reorder the execution of operands in the generated code to improve efficiency.
- Suppress Generation of Default Cases for Unreachable Stateflow Switch Statements
Specify if a default case is generated among switch-case statements.
- Replace Multiplication by Powers of Two with Signed Bitwise Shifts
Specify whether to replaces multiplication by powers of two with signed bitwise shifts.
- Generate Code Containing Right Shifts on Signed Integers
Specify whether the generated code contains right shifts on signed integers.
- Control Cast Expressions in Generated Code
Control the data type casts that the code generator specifies in the generated code.