Archived
This forum has been archived. Please start a new discussion on GitHub.
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:
file2.ice
When I try to run slice2java (or slice2anythingelse) on these files, I get the following errors:
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
file1.ice:
#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
#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:
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
0
Comments
-
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:#ifndef _COMMON_ICE #define _COMMON_ICE module file1 { struct File1Struct { int whatever; }; }; module file2 { struct File2Struct { int whatever; }; }; #endif // _COMMON_ICE
file1.ice:#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,
Dwayne0