Structured Text (ST) Coding Guidelines
Contents
Introduction ........................................................................................................................................................... 5
About this Document ................................................................................................................................ 5
Source Files ............................................................................................................................................................ 6
File Naming .................................................................................................................................................... 6
Naming Conventions ......................................................................................................................................... 7
Reserved Words ........................................................................................................................................... 7
Variable Naming .......................................................................................................................................... 7
White Spaces ......................................................................................................................................................... 8
New Lines ....................................................................................................................................................... 9
Indentation .................................................................................................................................................. 12
Line Length .................................................................................................................................................. 12
Comments ............................................................................................................................................................ 13
Data Type Declarations ................................................................................................................................... 14
Derived Type Declaration ....................................................................................................................... 14
Structure Declaration ............................................................................................................................... 14
Enumerated Type Declaration.............................................................................................................. 14
Function Declarations ...................................................................................................................................... 15
Variable Declaration ................................................................................................................................. 15
Statements ................................................................................................................................................... 15
Expressions .................................................................................................................................................. 16
Function Block Declarations .......................................................................................................................... 17
Code Reuse ........................................................................................................................................................... 18
Standard Defined Functions and Function Blocks ....................................................................... 18
User-Defined Functions and Function Blocks ................................................................................ 18
International Code Reuse Considerations ....................................................................................... 18
Safety and Real-Time Concerns in an Embedded Environment...................................................... 19
Error Codes ................................................................................................................................................... 19
Recursion and Stack ................................................................................................................................. 19
Loops .............................................................................................................................................................. 19
Floating Point Data Types ...................................................................................................................... 19
L1415499
·
Rev AA
·
December 2014
3