Thread overview
Module on importC
Oct 22, 2023
Andrea Fontana
Oct 22, 2023
Andrea Fontana
Oct 22, 2023
Adam D Ruppe
Oct 23, 2023
Walter Bright
Oct 23, 2023
jmh530
October 22, 2023

Hello,

Is there a way to set modules name for importc? Or to give importc a hint directly on C?

I'm trying to import a project with a struct like:

a/b/utils.c
a/b/interface.c

c/d/utils.c
c/d/interface.c

e/f/utils.c
e/f/interface.c

All files conflict with each other!

Andrea

October 22, 2023

On Sunday, 22 October 2023 at 22:23:23 UTC, Andrea Fontana wrote:

>

Hello,

Is there a way to set modules name for importc? Or to give importc a hint directly on C?

I'm trying to import a project with a struct like:

a/b/utils.c
a/b/interface.c

c/d/utils.c
c/d/interface.c

e/f/utils.c
e/f/interface.c

All files conflict with each other!

Andrea

Sorry, I should have posted this on the Learn forum, obviously.

Andrea

October 22, 2023

On Sunday, 22 October 2023 at 22:23:23 UTC, Andrea Fontana wrote:

>

Is there a way to set modules name for importc? Or to give importc a hint directly on C?

You might have luck with the -mv switch. I blogged about it here:

http://dpldocs.info/this-week-in-d/Blog.Posted_2023_06_05.html

Search for the word "importC" in there. It... kinda works.

But I consider this to be one of the biggest flaws of the importC system....

October 22, 2023
On 10/22/2023 3:23 PM, Andrea Fontana wrote:
> Is there a way to set modules name for importc? Or to give importc a hint directly on C?
> 
> I'm trying to import a project with a struct like:
> 
> ```
> a/b/utils.c
> a/b/interface.c
> 
> c/d/utils.c
> c/d/interface.c
> 
> e/f/utils.c
> e/f/interface.c
> ```
> 
> All files conflict with each other!

One way is to create a file "a_b_utils.c" with the contents:

```
#include "a/b/utils.c"
```

Repeat for the other files.
October 23, 2023
On Monday, 23 October 2023 at 00:45:10 UTC, Walter Bright wrote:
> On 10/22/2023 3:23 PM, Andrea Fontana wrote:
>> Is there a way to set modules name for importc? Or to give importc a hint directly on C?
>> 
>> I'm trying to import a project with a struct like:
>> 
>> ```
>> a/b/utils.c
>> a/b/interface.c
>> 
>> c/d/utils.c
>> c/d/interface.c
>> 
>> e/f/utils.c
>> e/f/interface.c
>> ```
>> 
>> All files conflict with each other!
>
> One way is to create a file "a_b_utils.c" with the contents:
>
> ```
> #include "a/b/utils.c"
> ```
>
> Repeat for the other files.

I just want to repeat that I liked Steve's suggestion [1] to have a -CI flag for searching for .h files. Not sure that would solve the issue in this case, but I still liked it.

[1] https://github.com/dlang/dmd/pull/14864#issuecomment-1430650577