【问题标题】:error with array and object in IDL corbaIDL corba 中的数组和对象错误
【发布时间】:2013-04-16 17:37:56
【问题描述】:

IDL corba 中的数组和对象有问题 这是我的代码:

    interface ISinhVien
{
    SinhVien[] DocFile(in String filename);
    void GhiFile(in SinhVien[] sv,in String filename);
};

编译时出错:

CORBA_SinhVien>idlj -fall SinhVienIDL.idl
SinhVienIDL.idl (line 3):  SinhVien is an undeclared type.
        SinhVien[] DocFile(in String filename);
         ^
SinhVienIDL.idl (line 3):  Expected `<identifier>'; encountered `['.
        SinhVien[] DocFile(in String filename);
         ^
SinhVienIDL.idl (line 3):  WARNING: Identifier `String' collides with a keyword;
 use an escaped identifier to ensure future compatibility.
        SinhVien[] DocFile(in String filename);
                       ^
SinhVienIDL.idl (line 4):  SinhVien is an undeclared type.
        void GhiFile(in SinhVien[] sv,in String filename);
                         ^
SinhVienIDL.idl (line 4):  Expected `<identifier>'; encountered `['.
        void GhiFile(in SinhVien[] sv,in String filename);
                         ^
SinhVienIDL.idl (line 4):  WARNING: Identifier `String' collides with a keyword;
 use an escaped identifier to ensure future compatibility.
        void GhiFile(in SinhVien[] sv,in String filename);

请有人帮帮我!!!!!!!!!!!!!!!!!!!!!

【问题讨论】:

    标签: java arrays object corba idl


    【解决方案1】:

    CORBA language specification 不允许返回任何类型的数组,除非它们首先是typedefed

    这里有 2 个选项可用 - 固定数组或 sequences - 后者更灵活,允许由实现代码设置数组大小。

    interface SinhVien {
      boolean someOperation(in long id);
      // more operations
    };
    
    typedef sequence<SinhVien> sinhviens;
    
    
    interface ISinhVien
    {
        sinhviens docFile(in string filename);
        void ghiFile(in sinhviens sv, in string filename);
    };
    

    另外:注意不要将 Java 语法与 IDL 语法混用:string 全部显示为小写

    【讨论】:

    • 我在您的帮助下编辑代码!这是我的代码已编辑: typedef sequence sinhviens;接口 ISinhVien { sinhviens DocFile(在字符串文件名中); void GhiFile(在 sinhviens sv 中,在字符串文件名中); } 但出现错误:SinhVienIDL.idl(第 1 行):SinhVien 是未声明的类型。 typedef 序列 sinhviens;请帮帮我!!
    • 正如错误所说,您需要定义类型SinhVien。这可以是interfacestruct。您可以在同一个 IDL 文件中执行此操作,也可以使用 #include 指令
    • 你能详细解释一下吗?我是新的开始
    • 如前所述,您需要先定义SinhVien类型才能使用它。阅读此tutorial
    猜你喜欢
    • 2013-09-26
    • 2020-03-29
    • 1970-01-01
    • 2011-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多