Glossary · Automation fundamentals, platforms and components
Pointer
Also known as: Reference (REF_TO), POINTER TO
German: Pointer
In programming, a pointer is a variable that holds the memory address of another variable instead of a value. In IEC 61131-3 (3rd edition) the typed equivalent is a reference declared with REF_TO; many PLC environments also offer vendor-specific POINTER TO types.
- Automation components
In one sentence
A pointer stores the address of another variable; IEC 61131-3 offers typed references (REF_TO), vendors add their own pointer types.
Example
A function block receives a reference to a recipe array, so it can work on the data without copying 2 KB every PLC cycle.
How it applies
- Engineering: Pointers avoid copying large data such as Struct arrays and allow generic function blocks. Typed references (REF_TO) are safer than untyped addresses because the compiler checks the target type.
- Risk: Invalid or dangling pointers can overwrite memory or stop the controller. Many coding guidelines restrict pointer use, especially in safety-related code, and require a validity check before dereferencing.
- Documentation: Library documentation should state which parameters are passed by reference, whether the callee may change the data and how long the reference must remain valid.
Pointer vs. reference
A classic pointer can hold any address and supports arithmetic. An IEC 61131-3 reference points only to a variable of its declared type and has no arithmetic, which removes a whole class of errors. Vendor POINTER TO types sit in between; check the runtime documentation.