Skip to main content

Variable: VAR_GLOBAL

Important

If a local variable that is declared in a block has the same name as a global variable, then it has precedence within the block.

Important

For compiler version 3.2.0.0 and higher, CODESYS always initializes global variables before the local POU variables.

Global variables are variables, constants, external or remanent variables which are recognized within the entire project. You declare global variables in global variable lists or in the declaration part of programming objects between the keywords VAR_GLOBAL and END_VAR.

Example 86. Example
VAR_GLOBAL
    g_iVar1 : INT;
END_VAR


The system recognizes a global variable when you prepend the variable name with a dot (example: .g_iVar1).