Thread overview
[Issue 24127] ImportC - no way to organize files
Nov 20, 2023
Walter Bright
September 01, 2023
https://issues.dlang.org/show_bug.cgi?id=24127

Steven Schveighoffer <schveiguy@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ImportC

--
November 20, 2023
https://issues.dlang.org/show_bug.cgi?id=24127

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
The exact same thing happens when cstuff.c is actually named cstuff.d. But, when:

    module foo.bar.cstuff;

is added to cstuff.d, it compiles without error.

The trouble is, when a module statement is not present, the compiler names the module as if:

    module <filename>;

was present. <filename> is `cstuff`. The compiler does the same thing for .c files - it assigns a module name of `cstuff`, not `foo.bar.cstuff`.

This boils down to the fact that C files do not have a means to name the module. I think we're kinda stuck here.

--
November 20, 2023
https://issues.dlang.org/show_bug.cgi?id=24127

--- Comment #2 from Steven Schveighoffer <schveiguy@gmail.com> ---
(In reply to Walter Bright from comment #1)
> This boils down to the fact that C files do not have a means to name the module. I think we're kinda stuck here.

ImportC added import statements to C files, why not module statements?

--
February 09
https://issues.dlang.org/show_bug.cgi?id=24127

Chance Snow <git@chancesnow.me> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |git@chancesnow.me

--- Comment #3 from Chance Snow <git@chancesnow.me> ---
I'm experiencing this issue across Dub libraries. I maintain multiple libraries that had used the same name for C modules, e.g. "bindings.c". The compiler complains about module conflicts when an application depends on both libraries.

I am forced to workaround this issue by manually namespacing my C modules, e.g. "wgpu_bindings.c".

--
May 23
https://issues.dlang.org/show_bug.cgi?id=24127

Andrea Fontana <trikkuz@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trikkuz@gmail.com

--- Comment #4 from Andrea Fontana <trikkuz@gmail.com> ---
Similar problem here.

A C library with different file with the same name:

hello/utils.c
world/utils.c

dmd hello/utils.c world/utils.c

won't compile.

--