Search code examples
d

Import module in D from a sister folder?


Suppose I have the following directory structure for the project:

myproj/dir1/file1.d
myproj/dir2/file2.d
myproj/main.d

How can I import main and file2 modules within the source file file1.d?


Solution

  • file1.d will have module dir1.file1; line , file2.d will have module dir2.file2; line and main.d will start with module main;.

    Module declarations above will tell D what to do when it encounters line like: import main, dir2.file2;;

    As suggested by @sigod , read the http://dlang.org/module.html for more information.