SA0011: Useless declarations with only one component
Function | Determines structures, unions, or enumerations with only one component. |
Reason | No structures, unions or enumerations with only one component 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 an element can be replaced by a constant. |
Importance | Low |
PLCopen rule | CP22/CP24 |
Sample 1 – Structure:
TYPE ST_SingleStruct : // => SA0011
STRUCT
nPart : INT;
END_STRUCT
END_TYPESample 2 – Union:
TYPE U_SingleUnion : // => SA0011
UNION
fVar : LREAL;
END_UNION
END_TYPESample 3 – Enumeration:
TYPE E_SingleEnum : // => SA0011
(
eOnlyOne := 1
);
END_TYPE