Thread overview | |||||
---|---|---|---|---|---|
|
August 31, 2013 Relative imports and separate compilation | ||||
---|---|---|---|---|
| ||||
I've gone on TDPL and the language reference here but still don't get relative imports. I've isolated it to this: ./package1/package2/foo.d: import std.stdio; void doFoo() { writeln("Foo!"); } ./main.d: import package1.package2.foo; void main() { doFoo(); } This works: dmd -c main.d dmd -c package1/package2/foo.d dmd main.o foo.o This does not: dmd main.d package1/package2/foo.d main.d(1): Error: module foo from file package1/package2/foo.d must be imported as module 'foo' The only way I know of to make it work in the 2nd case is to use a module declaration at the top of foo. Which is what I've been doing so far. How to relative imports actually work? Atila |
August 31, 2013 Re: Relative imports and separate compilation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Atila Neves | On Saturday, 31 August 2013 at 09:29:16 UTC, Atila Neves wrote:
> How to relative imports actually work?
>
> Atila
Actually for me it looks like it is a bug in automatic module name deduction. It should always use full qualified name built from directory path from closest import folder (set by -I , current working directory by default) to actual module file. So behavior observed in separate compilation case is correct one - don't know what actually happens in second case.
|
September 03, 2013 Re: Relative imports and separate compilation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dicebot | I wouldn't mind so much if just "regularly" compiling, just do each file in turn. The problem is this how rdmd calls dmd and then things don't work as they should.
On Saturday, 31 August 2013 at 12:06:00 UTC, Dicebot wrote:
> On Saturday, 31 August 2013 at 09:29:16 UTC, Atila Neves wrote:
>> How to relative imports actually work?
>>
>> Atila
>
> Actually for me it looks like it is a bug in automatic module name deduction. It should always use full qualified name built from directory path from closest import folder (set by -I , current working directory by default) to actual module file. So behavior observed in separate compilation case is correct one - don't know what actually happens in second case.
|
Copyright © 1999-2021 by the D Language Foundation