dmd: Module X conflicts with itself (Was: Re: RDMD on Windows)

Nick Sabalausky a at a.a
Sat Aug 21 17:10:21 PDT 2010


"Andrej Mitrovic" <andrej.mitrovich at gmail.com> wrote in message 
news:i4pkg0$2a5h$1 at digitalmars.com...
> Man, I have no idea what's going on. I was trying out building with 
> xfbuild, and I keep getting different results on each attempted build:
>
[snip]
>
> Geeeeeeeeeeeeeeez.. What am I supposed to use to compile the files? DSSS 
> doesn't work, xfbuild seems broken most of the time,

If passing the files directly to DMD doesn't work, then none of the 
front-ends to DMD are going to work either.

Regarding xfbuild, yea, I've also noticed occasional "works differently on 
different runs" issues to. Kind of annoying, but anytime that happens, I 
clean out all the "obj"s and all of xfbuild's temp files, and do a fresh 
"xfbuild". Whatever happens on that run I consider "xfbuild's 'normal' 
behavior", and then anything that happens differently on the next run I just 
assume is an xfbuild bug.


> and I can't even use DMD with a simple directory structure like this:
>
> root\myproject.d
> root\myfolder\another.d
>
> myproject.d:
> module myproject;
>
> import myfolder.another;
>
> void main()
> {
> }
>
>
> another.d:
> module another;
>
> void fun(long n)
> {
> }
>
> C:\test>dmd -ofmain.exe myproject.d myfolder\another.d
> myproject.d(3): Error: module another from file myfolder\another.d 
> conflicts with another module another from file myfolder\another.d
>

I get the same result, but that's because that code is wrong:

Your "myproject.d" is trying to import a module named "myfolder.another", 
but you're setting "another.d"'s module to be "another". They both need to 
match (D packages/modules are absolute, not relative). So either change them 
both to "myfolder.another" (or change them both to just "another", but 
that's less recomended since you'd be splitting a package across different 
directories). Then it'll work.

Come to think of it...that might be your original problem... In your 
"acme\goodies\io.d", you're not setting the module name. I'd bet that DMD is 
assuming it to be just simply "io". And in main.d you're trying to import a 
"acme.goodies.io", so they don't match. It's a good idea to always include a 
"module" statement in every file for any multi-module project.

Try adding "module acme.goodies.io;" to your "io.d". That should fix the 
problem. Doing that works for me on both dmd and rdmd.

Or, if "io.d" is from some third party library, and you don't want to go 
changing it's internals, then do this:

1. In "main.d", change "import acme.goodies.io;" to "import io;"
2. Add "-Iacme\goodies" to the command-line. This tells DMD to consider 
"acme\goodies" to be one of the places (along with "." and "{path to 
phobos}") it sees as the "root" of the package hierarchy.

Note that "-I" doesn't work with the RDMD currently in trunk, but it's fixed 
in my rdmdAlt.d: 
http://www.dsource.org/projects/semitwist/browser/trunk/rdmdAlt.d





More information about the Digitalmars-d-learn mailing list