在* .idl文件中包含class.h文件会产生错误

时间:2012-07-19 10:39:06

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

我在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 ++文件:


    omniidl -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);
};

1 个答案:

答案 0 :(得分:2)

import无效IDL。也许你的意思是#include?但是你的User.h文件是用C ++编写的。它需要在IDL中。

相关问题