[Issue 24127] New: ImportC - no way to organize files
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 1 11:20:47 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24127
Issue ID: 24127
Summary: ImportC - no way to organize files
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at gmail.com
Created attachment 1889
--> https://issues.dlang.org/attachment.cgi?id=1889&action=edit
Tarball of example code to try
When a C file is imported through a path other than the root path, the compiler
can use the C file's declarations from a root module (one that is passed on the
compile line). However, when the C file is also passed on the command line, the
compiler complains that the file can only be imported as a non-packaged file.
I have attached an example, reproduced here:
```c foo/bar/cstuff.c
void fn() {}
```
```d foo/bar/dstuff.d
module foo.bar.dstuff;
import foo.bar.cstuff;
void main()
{
fn();
}
```
When compiling both on the command line:
```
steves at homebuild:~/importcbug$ dmd foo/bar/*
foo/bar/dstuff.d(3): Error: module `cstuff` from file foo/bar/cstuff.c must be
imported with 'import cstuff;'
```
However, when compiling the C module separately it succeeds:
```
steves at homebuild:~/importcbug$ dmd -c foo/bar/cstuff.c
steves at homebuild:~/importcbug$ dmd foo/bar/dstuff.d cstuff.o
steves at homebuild:~/importcbug$ ./dstuff
```
--
More information about the Digitalmars-d-bugs
mailing list