dmd -I flag - how to use?

gareis dhasenan at gmail.com
Mon Jun 4 20:12:54 PDT 2007


Daniel Keep palsalge
> 
> I think perhaps you're misunderstanding; the help message is correct.
> -Ipath is for telling the compiler where to search for modules that are
> imported by the program.  Any arguments you specify on the command line
> (outside of options) are file paths; not fully-qualified module names.
> 
> Let's say you have this:
> 
> d:\x\
>   foo.d
> 
> d:\y\
>   whatever.d	-- contains "import foo;"
> 
> Let's say you open a command-prompt.  Now,
> 
>   cd d:\y
>   dmd whatever.d
> 
> will fail because the compiler won't be able to find "foo".
> 
>   cd d:\y
>   dmd -Id:\x whatever.d
> 
> will work because now the compiler knows where to look for imported
> modules.  If you
> 
>   cd d:\x
>   dmd whatever.d
> 
> This won't work because there is no file called "whatever.d" in your
> current directory.  Similarly,
> 
>   cd d:\x
>   dmd -Id:\y whatever.d
> 
> Won't work because there *still* isn't a file called "whatever.d" in
> your current directory; the compiler doesn't care about what paths
> you've given it via -I: "whatever.d" is a relative or absolute file
> path, not a fully-qualified module name.
> 
> This also works:
> 
>   cd d:\
>   dmd -Ix y\whatever.d
> 
> However, let's say that whatever also contains "import bar;", and
> "bar.d" is located in d:\y.  In this case, the above would fail; you
> would need to do this:
> 
>   cd d:\
>   dmd -Ix -Iy y\whatever.d

One last example:
---
// d:\x\whatever.d
import foo.bar; // in d:\y\foo\bar.d
---

cd d:\x
dmd -Id:\y whatever.d





More information about the Digitalmars-d mailing list