【问题标题】:Including a class.h file in a *.idl file gives errors在 *.idl 文件中包含 class.h 文件会产生错误
【发布时间】:2012-07-19 10:39:05
【问题描述】:

我在 Corba 中有一些简单的界面:

#ifndef __INTERFFACE_IDL__
#define __INTERFFACE_IDL__

import User.h;

interface Interfface {  void fun(in User u); };

#endif

我也有简单的 C++ 类 User.h 和私有字段:firstName、lastName、age 以及 getter 和 setter。我使用omniORB,并尝试将我的界面翻译成C++文件:

omn​​iidl -bcxx interface.idl

但它给了我这些错误:

omniidl -bcxx interface.idl
interface.idl:4: Syntax error in definition
interface.idl:4: Syntax error in abstract valuetype
interface.idl:8: Error in look-up of 'User': 'User' not found
omniidl: 3 errors.

User.h 与 interface.idl 位于同一文件夹中。怎么了?

这段代码:

#ifndef __INTERFFACE_IDL__
#define __INTERFFACE_IDL__

**import test/User.h;**

interface Interfface {  void fun(in User u); };

#endif

给出相同的错误...

编辑:

我的 User.h 文件:

#include <string>
using std::string;

class User
{
    private :
            string firstName;
            string lastName;
            int age;
    public :
            string getFirstName();
            string getLastName();
            int getAge();
            void setFirstName(string);
            void setLastName(string);
            void setAge(int);
};

【问题讨论】:

  • 看起来它在抱怨 User.h 内部的东西,所以你必须发布它。
  • @Useless :好的,我在第一篇文章中发布了 User.h 代码
  • IDL 不是 C++。您还必须为 IUser 编写接口定义。
  • @Hans Passant:但是怎么做呢?我还想添加到我的用户类运算符 ==、= 和复制构造函数。如何在 IDL 中编写它?以及以后如何在interface.idl中包含IUser?

标签: c++ compiler-errors corba idl omniorb


【解决方案1】:

import 不是有效的 IDL。也许你的意思是#include?但是您的 User.h 文件是 C++ 文件。它需要在 IDL 中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-12
    • 2011-10-12
    • 1970-01-01
    • 2015-06-21
    • 1970-01-01
    • 1970-01-01
    • 2012-08-13
    • 2021-03-18
    相关资源
    最近更新 更多