Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-26-2006
mefoster mefoster is offline
Registered User
 
Name: Mary Ellen Foster
Organization: Technical University of Munich
Project: JAST human-robot dialogue system
 
Join Date: Jun 2006
Posts: 78
Circular #include possible?

So, say I want to accomplish something like the following, with two .ice input files, each of which needs to use types defined in the other.

file1.ice:
Code:
#ifndef _FILE1_ICE
#define _FILE1_ICE

#include "file2.ice"

module file1 {
    struct File1Struct {
        int whatever;
    };
    interface Test {
        void doSomething( ::file2::File2Struct test );
    };
};

#endif _FILE1_ICE
file2.ice
Code:
#ifndef _FILE2_ICE
#define _FILE2_ICE

#include "file1.ice"

module file2 {
    struct File2Struct {
        int whatever;
    };
    interface Test {
        void doSomethingElse( ::file1::File1Struct test );
    };
};

#endif _FILE2_ICE
When I try to run slice2java (or slice2anythingelse) on these files, I get the following errors:
Quote:
file1.ice:11: `file2::File2Struct' is not defined
file2.ice:11: `file1::File1Struct' is not defined
Is there any way to accomplish this, or do I need to choose some other configuration of .ice files to get what I want?

Thanks,

MEF
__________________
Mary Ellen Foster
Technical University of Munich
JAST human-robot dialogue system
Maintainer of Fedora Ice packages
Reply With Quote
  #2 (permalink)  
Old 09-26-2006
dwayne's Avatar
dwayne dwayne is offline
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 209
Hi,

You most likely will need to choose some other configuration of slice files, such as adding a third slice file that includes those types needed by other slice file.

common.ice:
Code:
#ifndef _COMMON_ICE
#define _COMMON_ICE

module file1 {
    struct File1Struct {
        int whatever;
    };
};

module file2 {
    struct File2Struct {
        int whatever;
    };
};

#endif // _COMMON_ICE
file1.ice:
Code:
#ifndef _FILE1_ICE
#define _FILE1_ICE

#include "common.ice"

module file1 {
    interface Test {
        void doSomething( ::file2::File2Struct test );
    };
};

#endif _FILE1_ICE
In some cases you would be able to use forward declaration to avoid having to do this, but in your example the types are structs, which cannot be forward declared.

Regards,
Dwayne
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
include order matters? ctennis Help Center 1 02-02-2007 02:22 PM
The ice include path... sac_urs Help Center 6 11-29-2005 03:03 AM
Question about #include AlexKom Help Center 3 07-20-2005 12:15 PM
slice2cpp & --include-dir vukicevic Bug Reports 2 12-02-2003 11:40 PM
generated #include clemens Help Center 1 06-04-2003 08:21 AM


All times are GMT -4. The time now is 10:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.