Attention

These docs are a bit ambitious. The steps described are accurate but IronPLC cannot yet run programs.

P0016

Code

P0016

Message

Variable is constant but does not define value

This error occurs when a variable is declared as constant but does not define an initial value.

Example

The following code will generate error P0016:

VAR_GLOBAL CONSTANT
    ResetCounterValue : INT;  (* Error: CONSTANT variable must have initializer *)
END_VAR

The variable ResetCounterValue is declared as CONSTANT but does not have an initial value assigned.

To fix this error, provide an initial value for the constant variable:

VAR_GLOBAL CONSTANT
    ResetCounterValue : INT := 17;  (* Correct: CONSTANT variable has initializer *)
END_VAR