标识符
您可以配置代码生成器如何为代码结构生成标识符。按照标识符命名规则生成有意义、唯一且可追溯的标识符。您可以在模型配置集、代码映射编辑器和 Embedded Coder® 字典中使用标识符命名规则。
您可以控制生成的标识符的最大长度,并包含名称修饰文本以避免名称冲突。您可以通过在正则表达式中使用标记修饰符来控制标识符的内容。某些关键字不能作为有效的标识符,例如 C 和 C++ 中的关键字。
函数
RTW.reservedIdentifiers | Get reserved identifiers for code generation (自 R2023b 起) |
主题
- Identifier Format Control
You can customize generated identifiers by using identifier naming rules.
- Modify Identifier Format Tokens by Using Token Decorators
Specify modifications to expanded values of identifier format tokens.
- Specify Boolean and Data Type Limit Identifiers
Integrate the generated code with your code by specifying the identifiers that correspond to Boolean
falseandtrue. Also, specify the identifiers that correspond to data type limits, which the generated code uses to determine overflows. - 保留关键字
如果使用代码生成器生成 C 或 C++ 代码,模型中不能包含为内部使用保留的关键字。
- Avoid Identifier Naming Collisions
Use model configuration parameters and best practices to avoid identifier collisions and maintain traceability in generated code.
