C circular dependency

Seems like you shouldn’t need to include anything in any of the files. A forward declaration of the relevant types should be sufficient: #ifndef MapTest_vertex_h #define MapTest_vertex_h struct edgelist; typedef struct { char* name; float x, y; edgelist* edges; // C++ only – not C } vertex; #endif etc. In C coding, you have to … Read more

Circular C++ Header Includes

Is this kind of cross-inclusions are prohibited? Yes. A work-around would be to say that the ifr member of mainw is a reference or a pointer, so that a forward-declaration will do instead of including the full declaration, like: //#include “IFr.h” //not this class IFr; //this instead … class mainw { public: static IFr* ifr; … Read more

Resolve circular typedef dependency?

The answer lies in the difference between declaration and definition. You are attempting to declare and define in the same step (in the case of a new type via typedef). You need to break these up into different steps so the compiler knows what you are talking about in advance. typedef struct Person Person; typedef … Read more

Why do circular imports seemingly work further up in the call stack but then raise an ImportError further down?

I think the answer by jpmc26, while by no means wrong, comes down too heavily on circular imports. They can work just fine, if you set them up correctly. The easiest way to do so is to use import my_module syntax, rather than from my_module import some_object. The former will almost always work, even if … Read more