SA0044: Declarations with reference to interface
Function | Determines declarations with REFERENCE TO <interface> and declarations of VAR_IN_OUT variables with the type of an interface (realized implicitly via REFERENCE TO). |
Reason | An interface type is always implicitly a reference to an instance of a function block that implements this interface. A reference to an interface is therefore a reference to a reference and can lead to unwanted behavior. |
Importance | High |
Samples:
I_Sample is an interface defined in the project.
Function block FB_Sample:
FUNCTION_BLOCK FB_Sample
VAR_INPUT
iInput : I_Sample;
END_VAR
VAR_OUTPUT
iOutput : I_Sample;
END_VAR
VAR_IN_OUT
iInOut1 : I_Sample; // => SA0044
{attribute 'analysis' := '-44'}
iInOut2 : I_Sample; // no error SA0044 because rule is deactivated via attribute
END_VARMAIN program:
PROGRAM MAIN
VAR
fbSample : FB_Sample;
iSample : I_Sample;
refItf : REFERENCE TO I_Sample; // => SA0044
END_VAR