Glossary · Automation fundamentals, platforms and components
Pragma
Also known as: Compiler directive
German: Pragma
In IEC 61131-3 programming, a pragma is an instruction to the programming tool or compiler, written in curly braces, that does not change the program's logic semantics but controls how it is compiled, displayed or exported. Pragma content is implementation-specific.
- Automation components
In one sentence
A pragma is a curly-brace instruction to the PLC compiler or tool, such as hiding a variable or controlling OPC UA symbol export.
Example
A developer adds a pragma above a variable declaration so that the variable is exported to the OPC UA server's symbol set.
How it applies
- Engineering: Pragmas control conditional compilation, warnings, symbol export, attribute assignment and similar tool behavior. Because their meaning is vendor-specific, code with pragmas is less portable between IEC 61131-3 environments.
- Review: A pragma can change which variables are visible to external clients, so it matters for access and security reviews. Include pragmas in code reviews, not only the logic.
- Documentation: Libraries that depend on pragmas should list them and explain their effect, for example which variables they expose through Symbol export. Record the tool version, because pragma support can change between releases.
Pragma vs. comment
Both are enclosed in special delimiters, but a comment (* ... *) is ignored by the compiler, while a pragma { ... } is read and acted on by it.