|
Within a record declaration you can place a union declaration without specifying a field name for the union object. The following example demonstrates the syntax for this:
type HasAnonUnion: record r:real64; union u:uns32; i:int32; endunion; s:string; endrecord; static v: HasAnonUnion;
Whenever an anonymous union appears within an record you can access the fields of the union as though they were direct fields of the record. In the example above, for example, you would access v's u and i fields using the syntax "v.u" and "v.i", respectively. The u and i fields have the same offset in the record (eight, because they follow a real64 object). The fields of v have the following offsets from v's base address:
v.r 0 v.u 8 v.i 8 v.s 12
@size(v) is 16 because the u and i fields only consume four bytes.
HLA also allows anonymous records within unions. Please see the HLA documentation for more details, though the syntax and usage is identical to anonymous unions within records.
|