标识符
您可以配置代码生成器如何为代码结构生成标识符。按照标识符命名规则生成有意义、唯一且可追溯的标识符。
您可以控制生成的标识符的最大长度,并包含名称修饰文本以避免名称冲突。您可以通过在正则表达式中使用标记修饰符来控制标识符的内容。某些关键字不能作为有效的标识符,例如 C 和 C++ 中的关键字。
主题
- Identifier Format Control
You can customize generated identifiers by specifying the Identifier format control parameters on the Code Generation > Identifiers pane in the Configuration Parameters dialog box.
- Specify Identifier Length to Avoid Naming Collisions
Use the Maximum identifier length parameter to limit the number of characters in function, type definition, and variable names.
- Specify Reserved Names for Generated Identifiers
Specify a set of names that the code generation process should not use.
- Customize Generated Identifier Naming Rules
Customize the naming of identifiers in the generated code.
- Avoid Identifier Name Collisions with Referenced Models
Specify parameter values to avoid identifier name collisions with referenced models.
- Control Name Mangling in Generated Identifiers
Specify the position and length of name-mangling text in generated identifiers.
- Specify Boolean and Data Type Limit Identifiers
Integrate the generated code with your code by specifying the identifiers that correspond to Boolean
false
andtrue
. Also, specify the identifiers that correspond to data type limits, which the generated code uses to determine overflows. - Reserved Keywords
If you use the code generator to produce C or C++ code, your model must not contain keywords that are reserved for internal use.
- Maintain Traceability for Generated Identifiers
To verify your model, you can trace back and forth between generated identifiers and corresponding entities within the model.
- Exceptions to Identifier Formatting Conventions
There are some exceptions to identifier formatting conventions for type names, non-
Auto
storage classes, and shared utilities. - Identifier Format Control Parameters Limitations
There are some limitations pertaining to how autogenerated identifiers comply with the setting of the Maximum identifier length parameter.