www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24668] New: ImportC: C files have no way to set module name

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 puremagic.com
          Reporter: dave287091 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.

--
Jul 20