SA0011: Useless declaration with only a single member
Detects structures or enumerations with only a single member
Justification: No structures or enumerations with only a single member should be declared. Such declarations can be confusing for readers. A structure with only one element can be replaced by an alias type. An enumeration with only one element can be replaced by an constant.
PLCopen rule: CP22 / CP24
Importance: Low
{attribute 'qualified_only'} {attribute 'strict'} TYPE SINGLE_ENUM : ( OnlyOne := 1 ); END_TYPE
TYPE SINGLE_UNION : UNION lrValue : LREAL; END_UNION END_TYPE
{attribute 'qualified_only'} {attribute 'strict'} TYPE SINGLE_ENUM : ( OnlyOne := 1 ); END_TYPE
Output in the Messages view:
SA0011: Useless declaration 'SINGLE_ENUM': Struct/Enum with only a single member should not be used
SA0011: Useless declaration 'SINGLE_UNION': Struct/Enum with only a single member should not be used
SA0011: Useless declaration 'SINGLE_STRUCT': Struct/Enum with only a single member should not be used