Code analysis (Static Analysis Light)

Before a project is loaded onto the target system, TwinCAT 3 PLC uses "Static Code Analysis" to check whether the source code follows specified coding guidelines.

Static Analysis Light

The license-free version of the static code analysis is called "Static Analysis Light". The checks configured there are automatically performed following each successful code generation. The required set of rules is defined in the PLC project properties under Static Analysis.

Deviations from the rules are issued as error messages in the Error List. Each rule has a unique number. If a violation of a rule is detected during the static analysis, the rule number is output in the error list together with an error description based on the following syntax. The abbreviation "SA" stands for "Static Analysis".

Syntax: "SA<rule number>: <rule description>"

Sample for rule number 33 (Unused variables): "SA0033: Not used: Variable 'bSample'"

Code analysis (Static Analysis Light) 1:

Libraries

TwinCAT only analyzes the application code of the current PLC project; the referenced libraries are ignored!

Code analysis (Static Analysis Light) 2:

Static Analysis Light is not executed in the event of compilation errors

Note that the Static Analysis Light is automatically executed following the successful compilation process. If, on the other hand, the code generation was not successful, i.e. if the compiler detected compilation errors, the Static Analysis Light is not executed.

Code analysis (Static Analysis Light) 3:

Punctual disabling of checks

You can use pragmas to disable checks for certain code parts: Pragmas and attributes for Static Analysis Light

Static Analysis Full

The licensed version of the static code analysis is the "Static Analysis", which has a greatly extended range of functions and configurations in comparison to the Light version. The static code analysis can be triggered manually or performed automatically during the code generation. Further information on this extension can be found in the documentation “TE1200 | TC3 PLC Static Analysis”.