Skip to main content

Compiler Error C0162

Message: Number <number of array values> of array initialisation is no constant value

Possible error cause: The initialization [Wert1,AnzahlWert2(Wert2)] works only with a constant for AnzahlWert2.

Error correction: Use constants only.

Example 405. Example of the error:
PROGRAM PLC_PRG
VAR
    i : INT := 3;
    arr1 : ARRAY[1..4] OF INT := [1,i(7)];
END_VAR

Message:

C0162: Number 'i' of array initialisation is no constant value

Error correction:

arr1 : ARRAY[1..4] OF INT := [1,3(7)];