How to import modules?

js.mdnq js_adddot+mdng at gmail.com
Mon Dec 3 20:31:39 PST 2012


I created a .d file having a class with the modules tag at the
top and everything public. I put it in a dir and used the -I flag
to include the path. When I import the file I get an undefined
method.

1. Do I need to compile the .d file into a lib or can I just
import the .d and have it included directly. This is easier so I
don't have to recompile when switching compilers.(to gdc)

2. Do I have to mark anything extern in the module?


In C/C++ one can just include the header, which contains code and
it will work. In D, it seems like one has to link in the methods
regardless? (at least when using the `imports <filename>`)

What I'm looking for is to get D to include the module using the
D file directly unless it exists in a lib file. (or at least
compile to a lib file and include it behind the scenes)



I'm also using dot notation.

module/import MyModules.ThisModule; then the path looks like
\Imports\MyModules\ThisModule.d. Not sure if this is the correct
way to organize modules or not.





More information about the Digitalmars-d-learn mailing list