kphp
kphp copied to clipboard
The problem of cyclic dependency with inheritance
Assume we have the following class hierarchy:
There is a a possible situation when such a hierarchy cannot be compiled. For example, if in any C++ Translation Unit inclusion of "С-class.h" or "D-class.h" will precede all other class headers of this hierarchy. The reason is in mechanism of header inclusion in KPHP.
A possible solution is following:
- To stop include class definition headers for properties and use only incomplete declarations.
- Include full class definitions for functions that uses such properties
Or we could just detect such situations and give human-readable error; for now it's g++ stage error:
...
error: expected class-name before ‘{’ token:
struct C$D: public C$D {
...
But, as I believe, the solution or detection would require analysis, which would take considerable time..