beckhoff TE1200 — 4.2.1.2.4 SA0024: Untyped literals

Configuration | Rules 4.2.1.2.3 SA0023: Complex return values | SA0023: Complex return values Sample: Structure ST_sample: TYPE ST_Sample : STRUCT n1 : INT; n2 : BYTE; END_STRUCT END_TYPE Example of functions with return value: FUNCTION F_MyFunction1 : I_MyInterface // no error FUNCTION F_MyFunction2 : ST_Sample // => SA0023 FUNCTION F_MyFunction3 : ARRAY[0..1] OF BOOL // => SA0023 4.2.1.2.4 SA0024: Untyped literals | SA0024: Untyped literals Sample: PROGRAM MAIN VAR nINT : INT := 10; // no error as no part of operation nDINT : DINT; nLINT : LINT; fREAL : REAL; fLREAL :

LREAL; END_VAR nINT := nINT + 34; // => SA0024 nINT := nINT + INT#34; // no error nDINT := nDINT + 23; // => SA0024 nDINT := nDINT + DINT#23; // no error nLINT := nLINT + 124; // => SA0024 fREAL := fREAL + 1.1; // => SA0024 fLREAL := fLREAL + 3.4; // => SA0024 TE1200 31 Version: 2.11.1 Function Determines complex return values that cannot be returned with a simple register copy of the processor. These include structures and arrays as well as return values of the type STRING (irrespective of the size of storage space occupied). Reason This is a performance warning.

If large values are returned as a result of a function, method, or property, the processor copies them repeatedly when the code is executed. This can lead to runtime problems and should be avoided if possible. Better performance is achieved if a structured value is passed to a function or method as VAR IN OUT and _ _ filled in the function or method. Importance Medium Function Determines untyped literals that are part of an operation. Reason Untyped literals are automatically typed depending on their use. In some cases, such as nDWORD := ROL(DWORD#1, i);, this can lead to unexpected situations where it is better to achieve clear clarification by using a typed literal. Importance Low