Cyclic dependency between module A and B
Steven Schveighoffer
schveiguy at gmail.com
Thu Apr 11 15:47:35 UTC 2019
On 4/10/19 2:52 PM, kdevel wrote:
> Recently (before refactoring) my application complained right after
> invocation:
>
> object.Error at src/rt/minfo.d(371): Cyclic dependency between module
> Filebrowser and App
> Filebrowser* ->
> App* ->
> Filebrowser*
>
> Is it possible to detect this dependency before the program is started?
> Perhaps during linking?
Unfortunately not, because D supports separate compilation, and
interface files (.di files). So the compiler can't necessarily know at
compile time that there is a cycle.
The suckiest part is that once it's compiled, and doesn't detect a
cycle, it's never going to have a cycle -- yet we run the algorithm to
detect it on every start up (we actually have to in order to properly
sort the static ctors). I'd love to get rid of that penalty.
-Steve
More information about the Digitalmars-d-learn
mailing list