GDC Compilation wtih Directory Present

Murloc justanotheraccount3212334 at proton.me
Fri Jun 16 06:26:34 UTC 2023


My project structure is the following:

```
Test
|
+-- pack
|   |
|   +-- file1.d
|   |
|   +-- file2.d
|
+-- program.d
```

And here is the code inside these files:

```d
// file2.d
package int value = -120;
```

```d
// file1.d
void printlnValueInFile2() {
     import std.stdio: writeln;
     import pack.file2: value;

     writeln(value);
}
```

```d
// program.d
void main() {
    import pack.file1;

    printlnValueInFile2(); // -120 expected
}
```

 From the directory Test when I'm trying to compile the project 
with command
`gdc -o program program.d pack/file1.d pack/file2.d`, it produces 
3 errors with the following messages:

- module `file1` from file `pack/file1.d` must be imported with 
'`import file1;`' (instead of '`import pack.file1`')
- module `file2` from file `pack/file2.d` must be imported with 
'`import file2;`' (instead of '`import pack.file2`')

Don't you need to provide a full path to these files relatively 
to the directory where the compilation process takes place (Test)?

- module `file2` member '`value`' is not visible from module 
'`file1`' (however, both files are in the same directory)


More information about the Digitalmars-d-learn mailing list