Compiler Error C0140

Message

Reference assign is only allowed to variables of REFERENCE type

Message Cause

An attempt is made to assign a reference value to a variable that is not defined as a reference type.

Solution

Define the variable as a REFERENCE type.

Error Example

PROGRAM PLC_PRG
VAR
 i : INT;
 I_r : INT;
END_VAR

I_r REF= i;

--> C0140: Reference assign is only allowed to variables of REFERENCE type

Error Correction

I_r : REFERENCE TO INT;