Bug 24668 – ImportC: C files have no way to set module name

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-07-20T22:47:18Z
Last change time
2024-12-13T19:36:31Z
Keywords
ImportC
Assigned to
No Owner
Creator
dave287091
Moved to GitHub: dmd#20488 →

Comments

Comment #0 by dave287091 — 2024-07-20T22:47:18Z
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.
Comment #1 by dave287091 — 2024-07-20T23:11:40Z
I think the fix is to just set the module name to the import path. In other words `a/foo.c` implies a `module a.foo;` declaration.
Comment #2 by robert.schadek — 2024-12-13T19:36:31Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20488 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB