Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

IDL union in C

IDL discriminated unions are mapped to a struct containing the discriminator and a C union of the branches of the IDL union, as they are in C++. See Broken Link for details.

Note: Types declared within a union will have the name of the enclosing union prepended to their names, as is done with definitions within modules and interfaces.

For example:

enum color
{
  RED,
  ORANGE,
  YELLOW,
  GREEN,
  BLUE
};

union u switch(color)
{
  case RED: 
   IFoo foo;
  case GREEN:
  case BLUE:
   long l;
  default:
   short s;
};

is mapped as:

// 'color' mapping omitted for brevity
typedef struct u
{
  color _d;
  union {
   IFoo* foo;
   int l;
   short int s;
  } _u;
} u;