【发布时间】:2012-08-18 08:40:23
【问题描述】:
我必须在我的学校项目中使用 idlj,但在我的 idl 文件中,我还需要使用前向声明。有人知道 idlj 是否支持前向声明吗?我试图这样做,但它给出了错误:
interface1.idl(第 34 行):有对 Class1 的前向引用,但是 它没有定义。
任何想法如何克服这个问题?不幸的是,我无法使用任何其他 idl 编译器......而且我找不到任何有关此的信息。
编辑:
interface1.idl:
interface SecondClass;
interface FirstClass
{
//...
};
interface2.idl:
interface FirstClass;
interface SecondClass
{
//...
};
idlj -fclient interface1.idl
给:
interface1.idl(第 8 行):有对 SecondClass 的前向引用, 但它没有定义。 }; ^
【问题讨论】:
-
几乎可以肯定。您可能会收到错误,因为您最终从未定义
Class1。没有看到你的 IDL 是不可能说的。 -
@Brian Neal:这很奇怪,请看一下我的编辑 - 我定义了
Class1(现在 velFirstClass) -
在某些时候,IDL 翻译器需要查看 SecondClass 的定义。
-
@Brian Neal: 好的,但这里
include不是解决方案——如果我使用include指令,我会有一个循环依赖...我不能在一个IDL 中同时拥有这两个接口文件 - 还有其他解决方案吗? -
在interface1.idl 的底部你可以#include interface2.idl 这样IDL 编译器最终可以看到Second class 是什么。它必须查看 SecondClass 的定义,以便为 FirstClass 生成正确的代码。