Cyclic depency with class static ctor

Jarrett Billingsley kb3ctd2 at yahoo.com
Thu Oct 26 15:29:03 PDT 2006


"Frank Benoit (keinfarbton)" <benoit at tionex.removethispart.de> wrote in 
message news:ehrblq$2do6$1 at digitaldaemon.com...
>I have project with many classes which also sometimes have static ctors.
> Now I get the runtime error "cyclic dependency in module ...".
>
> Is that a bug in the d runtime system, or is it just not documented,
> that this runtime error is also possible for static ctors?
>
> Now I have these 300+ ported classes, in 300+ modules. And they import
> each other and many of them have a static ctor. What can I do? How can I
> resolve the problems?

Put all the classes in one file.  No, seriously.  That's the proposed 
solution.

> I can think of the possibility to replace all "static this()" with a
> "public static void static_this()" and make a global module where i call
> all these ctor in a manual defined order. Is that the way to go?

I've done pretty much the equivalent in a lot of my projects.  It's just not 
really possible to mash together some modules which import each other, 
without putting most of the project into one module.  This error could 
probably be avoided with a smarter compiler, but now we're getting into QOI 
(quality of implementation) issues, and maybe not something which could be 
enforced by the spec.. 





More information about the Digitalmars-d mailing list