I've been trying out ImportC with libgit2 lately, and it's honestly a bit like magic!! Kudos to Walter for his work so far - this has been really cool. However, you may have seen Adam's blog post about the issue that D's module namespaces create, where a type imported from two different .c files aren't compatible with each other. There's a Bugzilla issue about it too, which Walter initially closed as WONTFIX because it seemed like it needed too difficult a fix.
Zig advertises a similarly "magic" C importing feature. I made an example trying a similar scenario to what Adam described, and it seems we're actually in "good company":
<proj path>/src/main.zig:11:16: error: expected type '.media.<username>.4ea9c2fa-455c-480d-adbd-b533afd47647.home.<username>.Coding.Zig.zigwithc.zig-cache.o.8cf07da78935aad995196c635ddb6192.cimport.struct_tm', found '.media.<username>.4ea9c2fa-455c-480d-adbd-b533afd47647.home.<username>.Coding.Zig.zigwithc.zig-cache.o.46100012acc16f9e9848385e1fd2122e.cimport.struct_tm'
clibB.doIt(thing);
^~~~~
<proj path>/zig-cache/o/46100012acc16f9e9848385e1fd2122e/cimport.zig:121:30: note: struct declared here
pub const struct_tm = extern struct {
~~~~~~~^~~~~~
<proj path>/zig-cache/o/8cf07da78935aad995196c635ddb6192/cimport.zig:121:30: note: struct declared here
pub const struct_tm = extern struct {
~~~~~~~^~~~~~
I'd like to know how they plan to solve this issue themselves... Maybe we can help each other out in this regard.
I asked Adam about it on the Discord, and his suggestion was:
>but there is a pretty easy solution to this in any case: make everything from importC be an alias back into an implicitly-created global namespace
What do you think? This at least seems like a sound idea.