Keyword "package" prevents from importing a package module "package.d"
Arafel
er.krali at gmail.com
Thu Nov 2 12:17:28 UTC 2023
On 02.11.23 12:57, BoQsc wrote:
> The current major problem is that it does not work on Windows operating
> system with either `rdmd` or `dmd`. While it does work on run.dlang.io.
The problem is with your import path.
If you say:
```d
import waffles;
```
The compiler would search for either `waffles.d` or `waffles/package.d`
**in your current working directory**.
So you have three options:
1. You can compile from the parent directory, most likely what
run.dlang.io does: `dmd -i -run waffles/program.d`
2. You can explicitly add all the files to the dmd invocation (I think
this is what dub does), although that likely defeats the purpose of
`rdmd` and `dmd -i`.
3. You can add `..` (the parent directory) to your search path: `dmd
-I.. [......]`
Actually, the cleanest (and in my view proper) solution would be to
create a new `waffles` directory with the "package" itself, and take the
main function out of it, so you'd have:
```
waffles
|
+-- program.d
|
+-- waffles
|
+-- package.d
|
+-- testing1.d
|
+-- testing2.d
```
More information about the Digitalmars-d-learn
mailing list