On Sun, 30 Jun 2013 19:58:51 -0400, Milvakili <[email protected]>
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