static init cycle detection problem
Steven Schveighoffer
schveiguy at yahoo.com
Mon Sep 24 08:05:50 PDT 2012
On Wed, 19 Sep 2012 16:25:46 -0400, Øivind <oivind.loe at gmail.com> wrote:
> I am struggeling to get around the cycle detection kicking in when I
> have static init in modules that depend on eachother.
>
> I have seen some threads on 'fixes' for this, e.g. adding a @standalone
> property to the module or similar. Has there been any progress on this?
No. If two initializations truly don't depend on each other, you can
initialize in their own module.
The issue is that you have to move *all* the initializations into their
own module. The compiler doesn't keep track of complex dependencies, it's
all on a module-level.
I redesigned the static cycle detection code a while back (it was broken
(allowed certain cycles) and much less informative), and I can say it was
a very difficult problem to solve.
> If not would it be possible in e.g. main() to get a list of all
> compiled-in modules, and then iterate over them and call an init
> function where it exists? As long as there is a way to list the name of
> the modules at compile-time, this should be pretty easy..?
No, you have no idea at compile-time what other modules will be linked in.
You need to do the cycle detection at link-time or run-time, and as long
as we use standard C linkers, we cannot add that feature.
-Steve
More information about the Digitalmars-d-learn
mailing list