[omniORB] structs and nested typedefs/structs

Stephen Crawley crawley@dstc.edu.au
Wed, 05 Jan 2000 14:00:29 +1000


> I'm trying to figure out whether it is legal to have
> type declarations inside structs. The documents I read
> aren't terribly clear about this issue and omniidl2 refuses
> the following declaration:
> 
> struct foo
> {
>   typedef long bar;
    ^^^
    this is not a <typespec>
>   struct boo { short s;};
                          ^
                          missing <declarator>
> };

The following version of the above is legal IDL.

  typedef long bar;
  struct foo {
    bar f1;
    struct boo {
      short s;
    } f2;
  };
> What is allowed inside structs and what isn't ?

A CORBA struct can contain any type declaration apart from a typedef 
as the type of a member.  But it is probably a bad idea to nest 
declarations inside structs >>unless<< you are defining a recursive 
data type.

I suggest you invest in a good textbook on CORBA.

-- Steve