[omniORB] omniidl compiler problem? (omniorbpy 2.1)

Duncan Grisby duncan at grisby.org
Thu Aug 28 15:53:04 BST 2003


On Thursday 28 August, Rene Jager wrote:

> On Thu, 2003-08-28 at 10:09, enrico.sirola at riskmap.it wrote:

[...]
> > $ omniidl.exe -bpython tree.idl
> > tree.idl:13: Cannot use sequence of forward-declared struct 'tree::Node' before it is fully defined
> > tree.idl:4:  ('Node' forward-declared here)

The error means exactly what it says: you are not allowed to use a
forward declared struct sequence before it is fully defined, unless
you are using it inside the definition of that struct. Section
3.10.2.3 of the CORBA 2.6 spec is quite clear about that. See the
bottom of page 3-39 and the top of page 3-40.

[...]
> the following would probably work:

> module tree {
>     enum NodeKind {IsLeaf, IsNotLeaf};
>
>     struct Node;
>     typedef sequence<string> StringSeq;
>
>     struct Node {
>         string tag;
>         union NodeContent switch (NodeKind) {
>         case IsLeaf:
>             StringSeq itemCodes;
>         case IsNotLeaf:
>             sequence<Node> childNodes;
>         } nc;
>     };
> };
> 
> ---------------------------
> 
> although omniidl gives:
> 
>    tree.idl:13: Warning: Anonymous sequences for recursive structures
>                    are deprecated. Use a forward declaration instead.
> 
> but I can't think of another solution right now if the forward declared
> stuff doesn't work...

You're almost there. This is valid, and doesn't elicit any warnings:

module tree {
    enum NodeKind {IsLeaf, IsNotLeaf};

    struct Node;
    typedef sequence<Node>   NodeSeq;
    typedef sequence<string> StringSeq;

    struct Node {
        string tag;
        union NodeContent switch (NodeKind) {
        case IsLeaf:
            StringSeq itemCodes;
        case IsNotLeaf:
            NodeSeq childNodes;
        } nc;
    };
};

It's legal this time, because the use of NodeSeq is inside the
definition of Node.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list