Rileva le strutture non impacchettate utilizzate nelle strutture impacchettate.
Giustificazione: In genere il compilatore imposta una struttura non impacchettata a un indirizzo che consente l'accesso allineato a tutti gli elementi della struttura. Se si crea questa struttura in una struttura impacchettata, l'accesso allineato non è più possibile. Inoltre, l'accesso a un elemento della struttura non impacchettata può portare a un'eccezione di disallineamento.
Importanza: Alto
Esempio
La struttura structSingleDataRecord è impacchettata, ma contiene le strutture non impacchettate struct4Byte e struct9Byte.
{attribute 'pack_mode' := '1'}
TYPE structSingleDataRecord :
STRUCT
str9ByteData: struct9Byte; (* 9 BYTE *)
str4ByteData: struct4Byte; (* 4 BYTE *)
udi1: UDINT;
udi2: UDINT;
udi3: UDINT;
usi4: USINT;
END_STRUCT
END_TYPE (* 9 BYTE *)
TYPE struct9Byte :
STRUCT
usiRotorSlots: USINT; (* 1 BYTE *)
uiMaxCurrent: UINT; (* 2 BYTE *)
usiVelocity: USINT; (* 1 BYTE *)
uiAcceleration: UINT; (* 2 BYTE *)
uiDeceleration: UINT; (* 2 BYTE *)
usiDirectionChange: USINT; (* 1 BYTE *)
END_STRUCT
END_TYPE TYPE struct4Byte :
STRUCT
//udiDummy : UDINT;
rRealDummy : REAL;
END_STRUCT
END_TYPE
--> SA0161: Declaration of an unpacked struct 'struct9ByteData' inside a packed struct 'structSingleDataRecord'
--> SA0161: Declaration of an unpacked struct 'struct4ByteData' inside a packed struct 'structSingleDataRecord'