On Sun, 15 Jan 2012 03:53:05 -0800, F i L <witte2...@gmail.com> wrote:

Given the code, test.d:

    import std.stdio;

    export void test()
    {
        writeln("Test");
    }

compiled with: # dmd -lib -H test.d
I end up with test.lib (good so far), and test.di:

    import std.stdio;

    export void test()
    {
    writeln("Test");
    }

wtf? why is test() fully represented? I thought interface files where suppose to be minimal, interface only structures (like C .h files). When I manually cut everything down to: "export void test();" everything still works fine, so why is DMD spitting out the implementation?

I'm assuming that your goal is to build either or static or dynamic libraries?

If that is the case than you can assume that CTFE and inlining will not work anyways. This is an inherent limitation of libraries and not D. What D currently does is assume that you want everything to work, and spits out your implementation code symbol-for-symbol. The only thing I've found that D ever strips out of DI files is unittests. I have written a patch for DMD that strips out non-template class/function implementations with the understanding that CTFE and inlining will no longer work. Templated functions and classes retain their implementations, this is in line with the way C++ operates. Unfortunately my patch isn't well tested yet so I haven't opened the pull required to get it included into the main line DMD code. But it's a available from my Git account [https://lightben...@github.com/LightBender/dmd.git] if you don't mind building DMD yourself.

--
Adam Wilson
Project Coordinator
The Horizon Project
http://www.thehorizonproject.org/

Reply via email to