View previous topic :: View next topic |
Author |
Message |
Shawn Liu
Joined: 09 Mar 2005 Posts: 104 Location: Shanghai, China
|
Posted: Wed Mar 30, 2005 3:08 am Post subject: static constructor issue:circular initialization dependency |
|
|
If two modules who has static constructor imports each other, an "circular initialization dependency " error occurs. This is a runtime error and can't detected at compile time (at least current version DMD can not).
To avoid this, Walter suggested that don't implement static initialization in both modules.
DWT has at least 3 or more modules with static constructor
display.d, os.d, widget.d ...
I think all static initialization should be done in os module, since user code (outside DWT) should never import os.d. This can avoid "circular initialization dependency" issue between DWT and user code.[/img]
Last edited by Shawn Liu on Wed Mar 30, 2005 10:25 pm; edited 2 times in total |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Wed Mar 30, 2005 10:08 am Post subject: |
|
|
Very good catch, Shawn. Those sections need their logic updated. |
|
Back to top |
|
|
Shawn Liu
Joined: 09 Mar 2005 Posts: 104 Location: Shanghai, China
|
Posted: Mon Apr 18, 2005 3:36 am Post subject: |
|
|
With more files added to project, call all those static ctor in OS becomes bothering. You must first import that module into OS module, the invoke the static ctor in static this() of OS. This make us fallible for forget to add some module's static ctor to OS module. There is another patient problem. OS module is used everywhere, but some module is seldom used or not used in some app. If we import all those module into OS. Can this increase the size of the executable file? I am not sure.
So, I prefer to call static ctor in its self module. Set a flag whether static ctor called before. And check the flag in static ctor. And invoke static ctor in all public ctor and public static motheds.
In this way, we can solove the "circular initialization dependency" and don't mess the OS module; |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|