beckhoff TE1200 — 4.2.1.1.16 SA0016: Gaps in structures

Configuration | Rules 4.2.1.1.15 SA0015: Access to global data via FB_init | SA0015: Access to global data via FB_init Sample: Global variable list GVL_App: VAR_GLOBAL nVar : INT; END_VAR Function block FB_Sample: FUNCTION_BLOCK FB_Sample VAR nLocal : INT; END_VAR Method FB_Sample.FB_init: METHOD FB_init : BOOL VAR_INPUT bInitRetains : BOOL; // if TRUE, the retain variables are initialized (warm start / cold start) bInCopyCode : BOOL; // if TRUE, the instance afterwards gets moved into the copy code (online change) END_VAR nLocal := 2*nVar; // => SA0015 MAIN program: PROGRAM MAIN VAR fbSample : FB_Sample; END_VAR 4.2.1.1.16 SA0016: Gaps in structures | SA0016: Gaps in structures Samples:

TYPE ST_UnpaddedStructure1 : STRUCT bBOOL : BOOL; nINT : INT; // => SA0016 nBYTE : BYTE; nWORD : WORD; END_STRUCT END_TYPE TYPE ST_UnpaddedStructure2 : STRUCT bBOOL : WORD; nINT : INT; nBYTE : BYTE; nWORD : WORD; // => SA0016 END_STRUCT END_TYPE TE1200 27 Version: 2.11.1 Function Determines access of a function block to global data via the FB init method. The value of _ this variables depends on the order of the initializations! Reason Depending on the declaration location of the instance of a function block, a non-initialized variable may be accessed if the rule is violated.

Importance High Function Determines gaps in structures or function blocks, caused by the alignment requirements of the currently selected target system. If possible, you should remove gaps by rearranging the structure elements or by filling them with dummy elements. If this is not possible, you can disable the rule for the affected structures using the attribute {attribute 'analysis' := '...'} [} 123]. Reason Due to different alignment requirements on different platforms, such structures may have a different layout in the memory. The code may behave differently, depending on the platform. Importance Low