[Issue 24668] New: ImportC: C files have no way to set module name
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jul 20 22:47:18 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24668
Issue ID: 24668
Summary: ImportC: C files have no way to set module name
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dave287091 at gmail.com
Consider the following source code layout:
```
main.d
a/
foo.c
```
with files
main.d:
```
import a.foo;
void main(){
a.foo.foo();
}
```
a/foo.c:
```
extern int puts(const char*);
void foo(void){ puts(“foo”); }
```
`dmd main.d` fails due to undefined reference to foo (as a/foo.c is not
compiled to object code). However, `dmd main.d a/foo.c` also fails with the
error “module `foo` from file a/foo.c must be imported with ‘import foo;’”. In
a D file you would declare “module a.foo;”, but there is no way to do that with
ImportC.
--
More information about the Digitalmars-d-bugs
mailing list