Odd compiler complaints with import declarations

Orfeo orfeo.davia at gmail.com
Fri Sep 13 12:54:29 PDT 2013


I have this  directory hierarchy (from TDPL pag 339):
.
├── acme
│   ├── gadget.d
│   └── goodies
│       └── io
│           ├── io.d
│           └── string.d
└── main.d

// in main.d
: import std.stdio;
:
: import acme.gadget;
: void main(string[] args) {
:    wun();
: }

// in gadget.d
: import std.stdio;
: import acme.goodies.io.string;
: public void wun() { }

When I try to compile with these files

: $ dmd  main.d acme/gadget.d acme/goodies/io/*.d -ofa

the compiler complains stating...

: main.d(3): Error: module gadget from file acme/gadget.d must be 
imported as module 'gadget'
: acme/gadget.d(3): Error: module string from file 
acme/goodies/io/string.d must be imported as module 'string'

But Andrei in his great TDPL writes (pag. 339):
"To import one module from another, specify the name of the 
module in an import
declaration. The name must include the relative path computed 
from the directory"

Where am I wrong?



More information about the Digitalmars-d-learn mailing list