View previous topic :: View next topic |
Author |
Message |
drobo
Joined: 17 Oct 2010 Posts: 3 Location: Oslo, Norway
|
Posted: Mon Oct 25, 2010 4:14 am Post subject: cyclic dependency between modules |
|
|
Hi
I'm trying to port a C library and I'm getting an error something like this:
module A cannot read file A.d
There is a cyclic dependency between two of the header files. Eg. they both include each other. Coming from C++ I find this to be bad design. Actually both the headers are quite large and each of them only seems to need a small potion of the other. I cannot with my best intention imagine how not factoring out the common pieces of code is anything else than lazyness.
Anyway, what i wanned to ask is if this cyclic dependency is considered bad practice in D, and if it could be the reason I get the error.
PS. I'm new to D and I find some error messages kind of confusing, so please bear with me if this is a no brainer |
|
Back to top |
|
|
mutable
Joined: 22 Jun 2010 Posts: 87
|
Posted: Mon Oct 25, 2010 6:34 pm Post subject: |
|
|
Try it with a private import. Otherwise post the code. |
|
Back to top |
|
|
drobo
Joined: 17 Oct 2010 Posts: 3 Location: Oslo, Norway
|
Posted: Mon Oct 25, 2010 8:25 pm Post subject: |
|
|
I managed to fix the error by using fully qualified names on the modules (wasn't sure if this was necessary as they were both in the same sub-folder)
That led me to another error along the lines of "module A conflicts with module A..."
so I figured I should combat the cyclic dependency by refactoring a couple of structs into a new module and import that. After that it works fine.
Anyway, thanks for the reply. I'll be sure to read up on private imports =) |
|
Back to top |
|
|
|