Rules / undeclared-global
Typo in a gvl.* global name: why CODESYS does not always complain
A gvl.<name> reference points to a variable that the global list does not declare, which is almost always a one-letter typo. Depending on project settings the code either fails to build or the program quietly works with a different variable while the intended one never gets a value.
Severity: Critical
Rule id: undeclared-global
Global name typo (gvl.*)
What the rule checks
A gvl.<name> reference has no declaration in the GVL, almost always a typo; the variable is silently created or the code won't compile.
What it does to the plant
A setpoint or command is written to the wrong place: the controller sees zero or a stale value while the HMI looks fine.
Example
VAR_GLOBAL rSupplyTemp : REAL; rSetpoint : REAL;END_VARPROGRAM PLC_PRGgvl.rSetpoint := gvl.rSuplyTemp + 5.0;
VAR_GLOBAL rSupplyTemp : REAL; rSetpoint : REAL;END_VARPROGRAM PLC_PRGgvl.rSetpoint := gvl.rSupplyTemp + 5.0;
Both listings are run through the linter by an automated test: the rule fires on the first and stays silent on the second.
How to fix
- Check the spelling against the GVL declaration (case, underscores, digits).
- If the variable is really needed, add it to the GVL with a type and a comment.
Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.
The same linter without uploading a file: command line and GitHub Action.
Related rules
2026-11-26