P4068¶
- Code
P4068
- Message
Function block member differs from the interface member it implements
This error occurs when a function block type implements an interface and declares one of the interface’s members, but with a different signature.
A method must have the same return type as the interface’s method, and the
same input, output and in-out variables: the same names, the same kinds and
the same types, in the same order. A string parameter must have the same
length, and an R_EDGE or F_EDGE input the same edge. Local variables
are not compared. A property must have the same type, and every accessor
(GET, SET) that the interface declares. An extra accessor is allowed.
A function block that extends a base which implements an interface implements it too, so a method or property it overrides must also match the interface’s.
Example¶
The following code will generate error P4068:
INTERFACE I_Comm
METHOD Send : BOOL
VAR_INPUT
data : INT;
END_VAR
END_METHOD
END_INTERFACE
FUNCTION_BLOCK FB_Serial IMPLEMENTS I_Comm
METHOD Send : BOOL
VAR_INPUT
data : DINT; (* Error: the interface declares INT *)
END_VAR
Send := TRUE;
END_METHOD
END_FUNCTION_BLOCK
To fix this error, declare the member exactly as the interface does:
FUNCTION_BLOCK FB_Serial IMPLEMENTS I_Comm
METHOD Send : BOOL
VAR_INPUT
data : INT;
END_VAR
Send := TRUE;
END_METHOD
END_FUNCTION_BLOCK
See Also¶
IMPLEMENTS —
IMPLEMENTSINTERFACE —
INTERFACEP4067 — Function block does not provide a member of an interface it implements
P4070 — IMPLEMENTS names a type that is not a declared interface
Think IronPLC is wrong about this?
If you believe this diagnostic is incorrect, open an issue on GitHub with a small sample that demonstrates the problem.