Generating headers with -H
Steven Schveighoffer
schveiguy at yahoo.com
Mon Nov 2 09:07:52 PST 2009
On Mon, 02 Nov 2009 11:53:12 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> This question may actually belong in .learn.
>
> What's exactly eliminated from the header generated with -H? I tried it
> just now and was surprised to see that the generated .di file includes
> the function bodies of regular (non-template) functions and methods.
>
> I was under the impression that generated headers exclude function
> bodies, and found documentation to support that viewpoint:
>
> http://www.digitalmars.com/d/2.0/dmd-windows.html#interface_files
>
> says:
>
> ============
> A D interface file contains only what an import of the module needs,
> rather than the whole implementation of that module.
>
> The advantages of using a D interface file for imports rather than a D
> source file are:
>
> * D interface files are often significantly smaller and much faster
> to process than the corresponding D source file.
> * They can be used to hide the source code, for example, one can
> ship an object code library along with D interface files rather than the
> complete source code.
> ============
>
> This strongly suggests that function bodies are eliminated. But what I'm
> seeing is that pretty much all function bodies are kept (exception:
> static this() functions are not), and only comments are removed.
>
> So what's -H really doing?
It removes whitespace and comments.
My understanding of why it does not remove implementations is for CTFE and
inlining.
Somehow I got it in my head that a significantly large enough function
would have it's body removed, but I can't remember why I think that...
Note that the above snippit from the docs suggests reasons for using d
interface files, *NOT* reasons for using dmd -H :)
-Steve
More information about the Digitalmars-d
mailing list