SA0005: Invalid addresses and data types

Function

Determines invalid address and data type specifications.

The following size prefixes are valid for addresses. Deviations from this lead to an invalid address specification.

  • X for BOOL
  • B for 1-byte data types
  • W for 2-byte data types
  • D for 4-byte data types

Reason

Variables that lie on direct addresses should, if possible, be associated with an address that corresponds to their data type width. It can be confusing for the reader of the code if, for example, a DWORD is placed on a BYTE address.

Importance

Low

SA0005: Invalid addresses and data types 1:

If the recommended placeholders %I* or %Q* are used, TwinCAT automatically performs flexible and optimized addressing.

Samples:

PROGRAM MAIN 
VAR
    nOK   AT%QW0   : INT;
    bOK   AT%QX5.0 : BOOL;
 
    nNOK  AT%QD10  : INT;        // => SA0005
    bNOK  AT%QB15  : BOOL;       // => SA0005
END_VAR