www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Module on importC

reply Andrea Fontana <nospam example.org> writes:
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
Oct 22 2023
next sibling parent Andrea Fontana <nospam example.org> writes:
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
Oct 22 2023
prev sibling next sibling parent Adam D Ruppe <destructionator gmail.com> writes:
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....
Oct 22 2023
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
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.
Oct 22 2023
parent jmh530 <john.michael.hall gmail.com> writes:
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
Oct 23 2023