https://issues.dlang.org/show_bug.cgi?id=16650

Vladimir Panteleev <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Vladimir Panteleev <[email protected]> ---
(In reply to Jacob Carlborg from comment #1)
> Not sure why it's called "stat_t" in the D version when it's
> called "stat" in the C headers.

It's because in C, "stat" is both the name of a struct and a function. This is
not a problem for C because structs in C have their own namespace (unless you
typedef them), but there is no equivalent in D.

There are some workarounds available:

- You can use extern(C) to link the D declaration with the C definition. As
argument types are not mangled with C linkage, type name mismatches will not
result in a link error.
- You can use pragma(mangle) on the D side to directly override a function's
mangled name;
- Finally, on the D side you could declare the function as:

struct stat;
void myFunc(stat*){}

then cast the stat_t* to stat* when invoking the function.

As this is not a bug in D and simple workarounds exist, I'll close this, but
feel free to reopen if you can present actionable ideas for improving the
situation.

--

Reply via email to