free quality report for PLCopenXML exports

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

Bad: the rule fires
VAR_GLOBAL    rSupplyTemp : REAL;    rSetpoint : REAL;END_VARPROGRAM PLC_PRGgvl.rSetpoint := gvl.rSuplyTemp + 5.0;
Fixed: the rule is silent
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

  1. Check the spelling against the GVL declaration (case, underscores, digits).
  2. If the variable is really needed, add it to the GVL with a type and a comment.
Check your project

Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.

Local version on GitHub →

The same linter without uploading a file: command line and GitHub Action.

Related rules

2026-11-26

Processing happens in memory, and the uploaded code is not stored. The tool advises; code changes are up to the engineer (see what the linter can't see). What happens to your code → · Rule reference · Your code & privacy · Industry benchmark · Feedback · GitHub