Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

Initializing unions

The members of a union can have initial values. However, if the union is static, only one member of the union can have the initial attribute. For nonstatic unions, initial attributes are applied in order of appearance. Subsequent initial values overwrite previous ones.

In the following example, the declaration for NT1 would be invalid if it had the static storage attribute.

  dcl
    1 NT1 union automatic,
      2 Numeric_translate_table1 char(256)
                     init( (256)'00'X),
      2 *,
        3 * char(240),
        3 * char(10) init('0123456789'),
      2 * char(0);
 
  dcl
    1 NT2 union static,
      2 Numeric_translate_table2 char(256),
      2 *,
        3 * char(        rank('0')    )
            init((1)(low(rank('0'))) ),
        3 * char(10) init('0123456789'),
        3 * char(         (256-(rank('0'))-10)    )
            init((1)(low( (256-(rank('0'))-10) )) ),

The declaration for NT2 is valid even though it has static storage class. Furthermore, the NT2 declaration is portable between EBCDIC and ASCII modes of execution.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)