The operator is an extension of the IEC 61131-3 standard.
The XSIZEOF operator determines the number of bytes which are needed in the passed variable or
data type.
In doing so, an unsigned value is always returned. The data type of the return value
<return value> is fixed as follows: type ULINT on 64-bit platforms and type UDINT on all other platforms. To generate code which runs on all platforms, the return
value can be declared with the __UXINT data type.
Syntax:
<return value> := XSIZEOF( <variable> );
Example in ST
PROGRAM PLC_PRG
VAR
uxiReturnValue : __UXINT; (* Datentyp bei 64-bit-Plattformen: ULINT *)
aData_1 : ARRAY[0..4] OF INT;
END_VAR
uxiReturnValue := XSIZEOF(aData_1);
uxiReturnValue = 10
uxiReturnValue = 10
In the case of assignment to a variable of type __UXINT, we recommend that you use the XSIZEOF operator instead of the SIZEOF operator. This is because with XSIZEOF the data type of the return value depends on the platform. As a result, any problems
when using the SIZEOF operator do not occur.