module dhelper is in file 'dhelper.d' which cannot be read

Steven Schveighoffer schveiguy at yahoo.com
Sun Jun 30 17:30:06 PDT 2013


On Sun, 30 Jun 2013 19:58:51 -0400, Milvakili <maliy.kayit at gmail.com>  
wrote:

> I'm new to D and got confused with the dmd.  I assume I have the  
> following codes in some folder x with all relevant extra files. Should  
> use .di files to import from other modules or the d file itself is  
> sufficient to import a module
>
> In c++, gcc -c x/cmain.cpp wil compile without any error.
>
> ****cmain.cpp***
> #include <iostream>
> #include "chelper.h"
>
> int main(){
>    std::cout << "Printing from cmain\n" ;
>    chelper_foo("cmain");
>    return 0;
> }
>
> In D, dmd -c x/dmain.d will complainsabout dhelper.d file which is in  
> the x folder.  What should I do to get  rid of this error?  dmd -c  
> x/dmain.d x/dhelper.d compiles but I do not want that.
>
> ****dmain.d***
> import std.stdio;
> import dhelper;
>
> void main(){
>    writefln("Hi from d");
>    dhelper_foo("dmain");
> }

The compiler can't find the dhelper source.  It looks in your search path,  
and then at the module path.

For example, if you did:

import x.dhelper;

it would compile main.  But then of course, dhelper better be told that  
it's x.dhelper and not just dhelper :)

// inside dhelper.d
module x.dhelper;

-Steve


More information about the Digitalmars-d mailing list