2012-07-19 90 views
1

我在CORBA的一些簡單的接口:包括在* .idl文件一個class.h文件給出了錯誤

#ifndef __INTERFFACE_IDL__ 
#define __INTERFFACE_IDL__ 

import User.h; 

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

#endif 

我也有簡單的C++類User.h與私有字段:名字,姓氏,年齡和獲得者和二傳手。我使用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); 
}; 
+0

看起來好像是在抱怨'User.h'裏面的東西,所以你必須發佈它。 – Useless 2012-07-19 11:51:49

+0

@Useless:好的,我在我的第一篇文章中發佈了User.h代碼 – mazix 2012-07-19 11:58:11

+1

IDL不是C++。您還必須爲IUser編寫接口定義。 – 2012-07-19 12:52:04

回答

2

import無效IDL 。也許你的意思是#include?但是你的User.h文件是用C++編寫的。它需要在IDL中。

+0

是的,你是對的;) – mazix 2012-07-30 13:10:20