Open dbankieris opened 3 years ago
I remember this. This has been a limitation from the beginning. I don't remember the details, but I do remember running into this exact scenario. I've been away from the code too long to give any suggestions off the top of my head on how we can fix this.
ICG produces iosrc code for a particular instantiation of a template in the `io*.cpp
of the containing class via [
FieldVisitor::ProcessTemplate`](https://github.com/nasa/trick/blob/0825b321183f71c1c54ebf4c6310660a4c1dbb1f/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp#L291).I/O code for
Foo<int>
andFoo<double>
is produced inio_Bar.cpp
.If a template instantiates another template as a member variable, an
io_*.cpp
is created for the containing template.I/O code for
Baz<int>
,Baz<double>
, andBaz<Onion>
is created inio_Potato.cpp
as usual.I/O code for
Foo<int>
,Foo<double>
, andFoo<Onion>
is produced inio_Baz.cpp
(which would normally not be created at all) because that's where the instantiations ofFoo
occur.The problem here is that
Onion
is defined inPotato.hh
, which is not known toBaz.hh
, which is the only header thatio_Baz.cpp
includes. The result is uncompilable I/O code.Including
Potato.hh
inio_Baz.cpp
fixes it, but I'm not sure if that's a general solution or how to even figure out that's necessary from within ICG. The header defining a particular type could be an arbitrary number of levels up the include chain. Perhaps the I/O code forFoo<int>
,Foo<double>
, andFoo<Onion>
should go inio_Potato.cpp
instead?Possibly related to #540 and #1001
@alexlin0 Thoughts?