Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportC: C files have no way to set module name #20488

Open
dlangBugzillaToGithub opened this issue Jul 20, 2024 · 1 comment · May be fixed by #20659
Open

ImportC: C files have no way to set module name #20488

dlangBugzillaToGithub opened this issue Jul 20, 2024 · 1 comment · May be fixed by #20659
Labels
Feature:ImportC Pertaining to ImportC support P1 Severity:normal

Comments

@dlangBugzillaToGithub
Copy link

dlangBugzillaToGithub commented Jul 20, 2024

dave287091 reported this on 2024-07-20T22:47:18Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=24668

Description

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.

@dlangBugzillaToGithub
Copy link
Author

dlangBugzillaToGithub commented Jul 20, 2024

dave287091 commented on 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.

@thewilsonator thewilsonator added the Feature:ImportC Pertaining to ImportC support label Dec 14, 2024
@dkorpel dkorpel linked a pull request Jan 8, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ImportC Pertaining to ImportC support P1 Severity:normal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants