[Issue 18031] Empty this compiles

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 4 18:50:40 UTC 2017


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

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
It's perfectly legal to declare functions without bodies. That's what you would
typically do in a .di file. The actual function body would then be in the
corresponding .d file. Most of the time, there's no reason to bother with .di
files, but in order for them to work, it's required that any function that does
not absolutely need its body to be present be able to not have its body present
(stuff like auto return functions and templated functions require their bodies,
but a normal function doesn't). Similarly, in some cases, the body may be in a
separate library entirely (though that's pretty much only with extern(C)
functions where the D declaration is just so that the D code can use an
existing C function).

You'll get a linker error as soon as you try to use the function if a function
body hasn't been linked in.

--


More information about the Digitalmars-d-bugs mailing list