Closed codingrhythm closed 5 years ago
No, records contain their fields "by value", meaning that a circularly-defined type would be of infinite size. If you need recursive types you need to implement them using custom interfaces, or come up with some other data format to pass them across the language boundary.
For your specific case, I think the list does indeed keep it from being infinite size at run-time, but at build time you can't define the C++ structs circularly, even with forward-declarations, since vector<T>
requires the full definition of T. A record representation which could break that dependency would have to use an extra layer of indirection via pointers or type-erasure, which isn't something intended by Djinni.
I have something similar to this
and the generated code failed to build for cpp and Objective-C because of the circular dependencies. Any ideas? for
interface
, Djinni uses forward declarations to break circular dependencies. Can we support this for record as well? Thanks