Currently the C++ code includes decl headers in .d.hpp files for all types found in the class, including in methods.
I think this will be a problem for self-containedness when we have two structs referencing each other
struct Foo {
a: Bar;
}
struct Bar { a: u8 }
impl Foo {
fn get_bar() -> Bar {}
}
impl Bar {
fn get_foo() -> Foo {}
}
You can see the problem this generates with the following two files, when you attempt to compile b.hpp. It goes away if you remove the #include "a.hpp" in b.hpp.
// a.hpp
#ifndef A_HPP
#define A_HPP
#include "b.hpp"
class B;
class A {
B b;
B toB();
};
#endif
// b.hpp
#ifndef B_HPP
#define B_HPP
#include "a.hpp"
class A;
class B {
int x;
A toA();
};
#endif
We should keep track of when we are generating struct fields vs methods and only add header dependencies for the former.
Currently the C++ code includes decl headers in
.d.hpp
files for all types found in the class, including in methods.I think this will be a problem for self-containedness when we have two structs referencing each other
You can see the problem this generates with the following two files, when you attempt to compile
b.hpp
. It goes away if you remove the#include "a.hpp"
inb.hpp
.We should keep track of when we are generating struct fields vs methods and only add header dependencies for the former.