dmd -c behaviour doesn't take account of packages.

Jonathan M Davis jmdavisProg at gmx.com
Wed Feb 22 14:05:40 PST 2012


On Wednesday, February 22, 2012 22:33:35 Bernard Helyer wrote:
> A discussion on the Mono-D IRC channel just made me realise
> something.
> 
> dmd -c foo/a.d bar/a.d
> 
> The second module overwrites the first. This makes using 'pass
> everything at once' with Mono-D (IDE plugin)
> difficult/impossible. As far as I'm concerned, it's just a bug
> that's never come up. The solution is trivial, of course. Prepend
> package names so you get foo_a.o and bar_a.o. Either that or
> allow specific output paths to be specified per-object.

Then what happens when you have

dmc -c foo/a.d foo_a.d

> Or just
> produce one object file. Anything _but_ the current behaviour, in
> fact.

Generating one object file would make far more sense.

If you're going to worry about modules when generating object files, then you 
really should be putting the object files in the same directory layout as the 
modules have. But that sort of thing is arguably a build tool's job, not the 
compiler.

Regardless, I really wouldn't like the idea of screwing with the object file 
names to try and avoid collisions. If anything, the compiler should complain 
that

dmd -c foo/a.d bar/a.d

will result in a conflict, because one file would overwrite the other. But the 
single object file solution sounds reasonable.

- Jonathan M Davis


More information about the Digitalmars-d mailing list