Skip to main content

Compiler Error C0186

Message: It is not possible to compare interface that is return value of call. Assign to variable first.

Possible error cause: A comparison operation is applied to an interface that is returned by a function.

Error correction: First assign the result of the function call to a variable and then compare the value of the variable. This will also reduce the number of function calls that are required.

Example 420. Example of the error:
INTERFACE MyInterface

FUNCTION GetInterface : MyInterface

PROGRAM PLC_PRG
IF GetInterface() <> 0 THEN
    // ...
END_IF

Message:

C0186: It is not possible to compare interface that is return value of call. Assign to variable first.

Error correction:

PROGRAM PLC_PRG
VAR_TEMP
    tempInterface : MyInterface;
END_VAR
tempInterface := GetInterface();
IF tempInterface <> 0 THEN
    // ...
END_IF