Archived
This forum has been archived. Please start a new discussion on GitHub.
ICE forward decls
in Help Center
While slice2cpp processes the following two ice modules successfully, it implements the classes IA::__U__As and IB::__U__Bs in a.h and b.h causing compile errors.
How can I avoid this without merging all the ice modules into one?
a.ice
How can I avoid this without merging all the ice modules into one?
a.ice
module IA { interface A; sequence<A*> As; }; module IB { interface B; sequence<B*> Bs; }; module IA { interface A { As GetAs(); IB::Bs GetBs(); }; };b.ice
module IB { interface B; sequence<B*> Bs; }; module IA { interface A; sequence<A*> As; }; module IB { interface B { Bs GetBs(); IA::As GetAs(); }; };
0
Comments
-
You should put the common types into a slice file and #include it from the other files.
ie:
seqtypes.icemodule IA { interface A; sequence<A*> As; }; module IB { interface B; sequence<B*> Bs; };
a.ice#include <seqtypes.ice> module IA { interface A { As GetAs(); IB::Bs GetBs(); }; };
0 -
Thanks, but this doesn't really help in my case
The problem is that I wanted further modules based on a.ice and b.ice. So if I build somethhing like atypes.ice and btypes.ice and include both of these in both a.ice and b.ice, i can compile all ice files correctly.
Now if I add a1.ice like so:#include <a.ice> module IA { interface A1 extends A { As booh(); IB::Bs baah(); }; };
It won't compile because slice basically ignores the #include <a.ice>.0 -
What exactly do you mean by slice ignores the include of a.ice? For C++ #include <a.ice> generates to #include <a.h>. Thefore you must compile not only a1.cpp but also a.cpp.0
-
I don't understand what you mean with "ignores #include<a.ice>". Can you elaborate?
Ice follows C++: You can have multiple declarations of types, but you can only define types once.0 -
Sorry, I got this all wrong. My problem was that I misspelled the module name in c.ice so slice2cpp didn't recognise interface A. Therefore, including a.ice or not had no impact. I thought the problem had to do with slice2cpp not handling nested includes.
Thanks for your help.0