On Thursday, 9 October 2014 at 18:21:32 UTC, WhatMeWorry wrote:
"To import one module from another, specify the name of the module in an import declaration. The name must include the relative path computed from the directory where compilation takes place"

This is not true. It is a REALLY common misconception, but it is not true. The import name must match the name given in the module declaration of the file.

So in the file you're importing, add "module your.name;" to the top. In the main file, import it as "import your.name;". If those two don't match, it will complain "cannot import module "foo" as "foo.bar"" or something like that.

It is recommended that the module name match the file name and folder name, but it is the module declaration at the top that matters, not the file/folder name.

Ok, but how does one determine where compilation takes place?

The directory from which you run the compiler. But the best way is to explicitly pass all the file names to the compiler:

dmd yourfile.d file2.d folder/file3.d and so on...

Doing that will serve you best in the long run, it will work with any module name and will link better too.

Reply via email to