www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Error: circular initialization dependency with module actor

reply orgoton <orgoton mindless.com> writes:
I have two modules mutually dependent, that means, module actor need module
queue which needs module actor. It all went fine with older compilers, but
with DMD1.0 I get "Error: circular initialization dependency with module
actor" when I try to run the program. How can I fix this?
Jan 15 2007
next sibling parent reply "Frank Benoit (keinfarbton)" <benoit tionex.removethispart.de> writes:
orgoton schrieb:
 I have two modules mutually dependent, that means, module actor need module
 queue which needs module actor. It all went fine with older compilers, but
 with DMD1.0 I get "Error: circular initialization dependency with module
 actor" when I try to run the program. How can I fix this?
remove one of the module ctors ("static this()"). http://www.digitalmars.com/d/module.html see section: Order of Static Construction
Jan 15 2007
parent reply Orgoton <orgoton mindless.com> writes:
Queue (class) has
"public Queue AIQ;"
defined at the end of the module file. This Queue is used on the default
constructor of Actor (a class). There is no static constructor on Actor. The
only
static thing on Queue is the symbol above. Queue however must store a list of
Actor's, hence it has an array of Actor. That is a private member of the Queue
class. Is this the origin of "Error: circular initialization dependency with
module actor"? Why didn't I have this error with previous versions?
Jan 15 2007
next sibling parent reply BCS <ao pathlink.com> writes:
Reply to Orgoton,

 Queue (class) has
 "public Queue AIQ;"
 defined at the end of the module file. This Queue is used on the
 default
 constructor of Actor (a class). There is no static constructor on
 Actor. The only
 static thing on Queue is the symbol above. Queue however must store a
 list of
 Actor's, hence it has an array of Actor. That is a private member of
 the Queue
 class. Is this the origin of "Error: circular initialization
 dependency with
 module actor"? Why didn't I have this error with previous versions?
Are you using code coverage (the -cov flag)?
Jan 15 2007
parent reply orgoton <orgoton mindless.com> writes:
== Quote from BCS (ao pathlink.com)'s article
 Reply to Orgoton,
 Queue (class) has
 "public Queue AIQ;"
 defined at the end of the module file. This Queue is used on the
 default
 constructor of Actor (a class). There is no static constructor on
 Actor. The only
 static thing on Queue is the symbol above. Queue however must store a
 list of
 Actor's, hence it has an array of Actor. That is a private member of
 the Queue
 class. Is this the origin of "Error: circular initialization
 dependency with
 module actor"? Why didn't I have this error with previous versions?
Are you using code coverage (the -cov flag)?
Yes, I am. I mean, I was. I removed the option and the program goes just fine. Thanks for the tip :P
Jan 15 2007
next sibling parent BCS <ao pathlink.com> writes:
Reply to Orgoton,

 == Quote from BCS (ao pathlink.com)'s article
 
 Reply to Orgoton,
 
 Queue (class) has
 "public Queue AIQ;"
 defined at the end of the module file. This Queue is used on the
 default constructor of Actor (a class). There is no static 
 constructor on Actor. The only static thing on Queue is the 
 symbol above. Queue however must store a list of Actor's, 
 hence it has an array of Actor. That is a private member of the 
 Queue class. Is this the origin of "Error: circular initialization 
 dependency with module actor"? Why didn't I have this error with 
 previous versions?
Are you using code coverage (the -cov flag)?
Yes, I am. I mean, I was. I removed the option and the program goes just fine. Thanks for the tip :P
That is a big problem (bug?) in DMD, -cov adds a static this that has dependencies (and shoudn't).
Jan 15 2007
prev sibling parent kenny <funisher gmail.com> writes:
I have circular dependencies in my code too. I think I solved it with 
"private import" -- and I also am using -cov (and that generates 
different linking errors for me, lol)

orgoton wrote:
 == Quote from BCS (ao pathlink.com)'s article
 Reply to Orgoton,
 Queue (class) has
 "public Queue AIQ;"
 defined at the end of the module file. This Queue is used on the
 default
 constructor of Actor (a class). There is no static constructor on
 Actor. The only
 static thing on Queue is the symbol above. Queue however must store a
 list of
 Actor's, hence it has an array of Actor. That is a private member of
 the Queue
 class. Is this the origin of "Error: circular initialization
 dependency with
 module actor"? Why didn't I have this error with previous versions?
Are you using code coverage (the -cov flag)?
Yes, I am. I mean, I was. I removed the option and the program goes just fine. Thanks for the tip :P
Jan 15 2007
prev sibling parent "Frank Benoit (keinfarbton)" <benoit tionex.removethispart.de> writes:
Orgoton schrieb:
 Queue (class) has
 "public Queue AIQ;"
 defined at the end of the module file. This Queue is used on the default
 constructor of Actor (a class). There is no static constructor on Actor. The
only
 static thing on Queue is the symbol above. Queue however must store a list of
 Actor's, hence it has an array of Actor. That is a private member of the Queue
 class. Is this the origin of "Error: circular initialization dependency with
 module actor"? Why didn't I have this error with previous versions?
All static ctor in a module have the same effect (module or class). The message indicates that there is a dependency problem related to static ctors. I try to explain what I understand: Before main is run, an algorithm tries to run all the existing static ctors. For each module, there is a list of all contained static ctors and a list of dependencies (the imports). It goes to the first modules and calls first recursively all modules that are listed in the dependencies. If it detects a circular dependency, the error is thrown. So, if you use other modules that include your modules or changed imports or you added static ctors, the behaviour can change. Tip: If you use static ctors, be careful with you imports. Can you reproduce, that this behaviour changed between DMD 1.00 the version before?
Jan 15 2007
prev sibling parent Alexander Panek <a.panek brainsware.org> writes:
orgoton wrote:
 I have two modules mutually dependent, that means, module actor need module
 queue which needs module actor. It all went fine with older compilers, but
 with DMD1.0 I get "Error: circular initialization dependency with module
 actor" when I try to run the program. How can I fix this?
The easiest and cleanest way would be to put the contents of those modules into one file.
Jan 15 2007