March 2010
Beginner
760 pages
18h 51m
English
Within a record declaration you can place a union declaration without specifying a fieldname 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 a 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 (8, 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) ...