我必须在我的学校项目中使用idlj,但在我的 idl 文件中我还需要使用前向声明。有谁知道 idlj 是否支持前向声明?我尝试这样做,但它给出了错误:
interface1.idl (line 34): There is a forward reference to Class1, but it is not defined.
有什么想法可以克服这个问题吗?不幸的是,我无法使用任何其他 idl 编译器......而且我找不到任何有关此的信息。
编辑:
接口(interface)1.idl:
interface SecondClass;
interface FirstClass
{
//...
};
接口(interface)2.idl:
interface FirstClass;
interface SecondClass
{
//...
};
idlj -fclient interface1.idl
给出:
interface1.idl (line 8): There is a forward reference to SecondClass, but it is not defined. }; ^
最佳答案
#ifndef _SecondClass
#define _SecondClass
#include "interface1.idl"
interface SecondClass
{
typedef sequence<FirstClass> firstVector;
SecondClass create();
};
#endif
#ifndef _FirstClass
#define _FirstClass
#include "interface2.idl"
interface FirstClass
{
typedef sequence<SecondClass> secondVector;
FirstClass create();
};
#endif
看看this 。将此模式用于所有相互依赖的接口(interface)。
关于java - idjl(Sun IDL 编译器)是否支持前向声明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12017191/