Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Reserved keyword used as a name

A reserved keyword was used in a position that expects a user-defined name (variable, parameter, POU, type alias, enum variant, struct field, …). Reserved keywords carry syntactic meaning and cannot double as identifiers.

Erroneous code example:

FUNCTION main
    VAR
        retain : DINT; // `RETAIN` is reserved
    END_VAR
END_FUNCTION

Rename the variable to something that is not a reserved keyword:

FUNCTION main
    VAR
        is_retained : DINT;
    END_VAR
END_FUNCTION

The same restriction applies to POU names, parameter names, type aliases, enum variants, struct fields, generic parameters, method names, and property names.

Note that VAR RETAIN ... END_VAR is still valid — there RETAIN is the variable-block modifier, not a variable name.