Skip to main content

Compiler Error C0041

Message: VAR_IN_OUT parameter '<parameter name>' of '<function name>' needs variable with write access as input

Possible error cause: The passed parameter is not a variable with write access (but a constant for example).

Error correction: Pass a VAR_IN_OUT parameter with write access to the function.

Example 340. Example of the error:
PROGRAM PLC_PRG
VAR
     i : INT;
     x : INT;
END_VAR
i := Test(31415);

FUNCTION TEST : INT
VAR_IN_OUT
    in_out: INT;
END_VAR

Message:

C0041: VAR_IN_OUT parameter 'in_out' of 'TEST' needs variable with write access as input

Error correction:

i := Test(x);