Search code examples
javacorbaidl

Does idjl (Sun IDL compiler) support forward declaration?


I have to use idlj for my school project but in my idl files I also need to use forward declaration. Does anybody know if idlj support forward declaration? I tried to do this, but it gives errors:

interface1.idl (line 34): There is a forward reference to Class1, but it is not defined.

Any ideas how to overcome this? I can't use any other idl compiler, unfortunately ... and I coudn't find any info about this.

EDIT:

interface1.idl:

interface SecondClass;

interface FirstClass
{
    //...
};

interface2.idl:

interface FirstClass;

interface SecondClass
{
    //...
};

idlj -fclient interface1.idl

gives :

interface1.idl (line 8): There is a forward reference to SecondClass, but it is not defined. }; ^


Solution

  • THIS VERSION OF MY CODE WORKED FINALLY (COMPILED WITH NO ERRORS) BUT I STILL DON'T KNOW HOW AND WHY ;P

    I dont know how and why but it finally compiled with no errors, take a look:

    File interface1.idl

    #ifndef __FIRSTCLASS_IDL__
    #define __FIRSTCLASS_IDL__
    
    #include "interface2.idl"
    
    interface FirstClass
    {
        typedef sequence<SecondClass> secondVector;
        FirstClass create();
    };
    
    #endif
    

    File interface2.idl

    #ifndef __SECONDCLASS_IDL__
    #define __SECONDCLASS_IDL__
    
    interface FirstClass;
    
    interface SecondClass
    {
        typedef sequence<FirstClass> firstVector;
        SecondClass create();
    };
    
    #include "interface1.idl"
    
    #endif
    

    I'm just a little bit confused why one include directive is at the top of the idl file, while the other one has to be at the bottom. Anybody knows that? Geez!