Naming conventions
In the Naming Conventions tab you can define naming conventions. Their compliance is accounted for in the Static Analysis execution. You define mandatory prefixes for the different data types of variables as well as for different scopes, function block types, and data type declarations. The names of all objects for which a convention can be specified are displayed in the project properties as a tree structure. The objects are arranged below organizational nodes.
Configuration of the naming conventions
Names | Nodes and elements for which a prefix can be defined The number in brackets after each element, for example "PROGRAM (102)", is the prefix convention number that is output if the naming convention is not followed. |
Prefix | You can define the naming conventions by entering the required prefix in this column. Please note the following notes and options:
|
Prefixes for variables | Organizational node for all variables for which a prefix dependent on their data type or scope can be defined |
Prefixes for POUs | Organizational node for all POU types and method validity ranges for which a prefix can be defined |
Prefixes for DUTs | Organizational node for the DUT data types Structure, Enumeration, Alias or Union for which a prefix can be defined |
Prefixes for user-defined types (NC0160) | Available from TC3.1 Build 4026 Organizational node for special user-defined types, especially those from libraries or for read-only types (e.g. PVOID, HRESULT)
Note: These conventions take priority over the prefixes defined with the {attribute 'nameprefix' := '<prefix>'} attribute. Example:
|
Formation of the expected prefix The prefix expected for the different declarations is formed depending on the configuration of the options found in the Naming conventions (2) dialog. On the Naming conventions (2) page you will also find explanations on how the expected prefix is formed, as well as some samples. |
Placeholder {datatype} with alias variables and properties Please also note the possibilities of the placeholder {datatype}, which you can use for the prefix definition of alias variables and properties. |
Local prefix definition for structured types For variables of structured types, you can specify a prefix locally in the data type declaration using the 'nameprefix' attribute. |
Syntax of convention violations in the message window
Each naming convention has a unique number (shown in parentheses after the convention in the naming convention configuration view). If a violation of a convention or a preset is detected during the static analysis, the number is output in the error list together with an error description based on the following syntax. The abbreviation "NC" stands for "Naming Convention".
Syntax: "NC<prefix convention number>: <convention description>"
Sample for convention number 151 (DUTs of type Structure): "NC0151: Invalid type name 'STR_Sample'. Expected prefix 'ST_'"
Temporary deactivation of naming conventions
Individual conventions can be disabled temporarily, i.e. for particular code lines. To this end you can add a pragma or an attribute in the declaration or implementation part of the code. For variables of structured types you may specify a prefix locally via an attribute in the data type declaration. For more information see: Pragmas and attributes.
Overview of naming conventions
For an overview of naming conventions, see Naming conventions – overview and description.