Duplicate interface methods with different signatures
POUs implementing multiple interfaces where both interfaces define a method with the same name are required to have the same signature for the method. A method signature is thereby defined by its name, return type and parameter list.
Errouneus code example:
INTERFACE interfaceA
METHOD foo : INT
VAR_INPUT
a : INT;
END_VAR
END_METHOD
END_INTERFACE
INTERFACE interfaceB
METHOD foo : DINT
VAR_OUTPUT
a : INT;
END_VAR
END_METHOD
END_INTERFACE
FUNCTION_BLOCK fb IMPLEMENTS interfaceA, interfaceB
// Signatures for foo differs, do we implement foo as defined in interfaceA or interfaceB?
END_FUNCTION_BLOCK
In the example above, the method foo
is defined in both interfaces interfaceA
and interfaceB
.
However, the return type of foo
in interfaceA
is INT
whereas in interfaceB
it is DINT
. Futhermore,
the parameter a
in interfaceA
is an input parameter whereas in interfaceB
it is an output parameter.
As a result both you and the compiler are left in doubt as to which method signature to implement in the
function block fb
and as a result the compiler will raise this error.