Definition Attributes
Data Definition Language (DDL) Reference Manual — 426798-002
6- 33
REDEFINES Clause
NOWARN command. The name of the union has the form
u_
first_member_name.
If the union name generated by DDL is the same as
any of its siblings defined in the same group, DDL issues an error message and
does not generate output.
The following example shows a DDL definition translated into a C declaration:
•
For Pascal, DDL translates a REDEFINES clause into a variant record.
The variants within the record are the data items of the redefined structure and the
data items of the redefining structure.
DDL generates integer case labels for each variant. For each REDEFINES clause,
the integer case labeling begins at 1.
If the REDEFINES clause is not the last item in its group, DDL generates an
anonymous record to contain the variant or variants. DDL then issues a warning.
DDL generates the variant record name by prefixing a V_ to the name of the first
structure being redefined. If the DDL-generated variant record name is the same
as any of its siblings defined in the same group, DDL issues an error message and
does not generate output.
Pascal does not do any run-time checking to enforce which variant is active at any
given time.
The following example shows the Pascal source code generated by DDL for a
REDEFINES clause. DDL generates an anonymous record (V_B) for the
REDEFINES B clause because this clause was not the last level 02 item in DEF A.
DDL did not generate an anonymous record for the REDEFINES D clause
because it was the last level 04 item in D, nor did DDL generate one for
REDEFINES E because it was the last level 02 item in DEF A.
DDL:
DEF A.
02 B PIC 9(4).
02 C REDEFINES B.
04 C-1 PIC 9(2).
04 C-2 PIC 9(2).
DDL
C Source
DEF a.
02 b PIC 9(4)
02 c PIC 9(6).
02 d PIC 9(6) REDEFINES c.
END
#pragma fieldalign shared2__a
typedef struct__a
{
char b[4];
union
{
char c[6];
char d[6];
} u_c;
} a_def;