|
|
RPC/XDR unions are discriminated unions, and look different from C unions. They are more analogous to Pascal variant records than they are to C unions.
union-definition: union union-ident switch ( simple declaration ) { case-list }This is an example of a type that might be returned as the result of a ``read data'' operation: if there is no error, return a block of data; otherwise, do not return anything.case-list: case value : declaration ; case value : declaration ; case-list default : declaration ;
union read_result switch (int errno) { case 0: opaque data[1024]; default: void; };This gets compiled into the following:
struct read_result { int errno; union { char data[1024]; } read_result_u; }; typedef struct read_result read_result;Notice that the union component of the output struct has the name as the type name, except for the trailing
_u
.