0

我在 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);

有人帮帮我,拜托!!!!!!!!!!!!!!!!!!!!!

4

1 回答 1

1

CORBA 语言规范不允许返回任何类型的数组,除非它们首先是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全部小写

于 2013-04-23T14:17:58.907 回答