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

Walter Bright <bugzi...@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzi...@digitalmars.com
         Resolution|---                         |INVALID

--- Comment #15 from Walter Bright <bugzi...@digitalmars.com> ---
This is actually a feature. I used it to good effect to define a function for
errno:

https://github.com/dlang/druntime/blob/master/src/core/stdc/errno.d#L34

    extern (C)
    {
        ref int _errno();
        alias errno = _errno;
    }

The actual function in the C runtime library returns an int*, but by making it
a ref int it will automatically dereference in D, enabling the simple use of
`errno` as in C.

Other uses are being able to hook up to functions based on their underlying
representation and bypass the stronger type checking D has. Such as FILE is a
shared type in D, but in C it's just another type. Sending it as extern(C) is
very convenient.

--

Reply via email to