boilerplate mixin

This page describes the boilerplate for making a Windows DLL: http://dlang.org/dll.html

(note that it contradicts code later on that *same page* in the COM section! But the code in the COM section is wrong - it crashes on Windows XP - while the code up top is correct.)

But D rox, we don't need boilerplate. We can use a mixin template with a generic main. I used this in my cgi.d and loved it and it looks like a perfect fit for this too.

This pull request takes the boilerplate from that dll page and puts it in so you can simply


    version(Windows) {
        import core.sys.windows.dll;
        mixin GenericDllMain!();
    }

in your dll file and really minimize the pointless copy pasta. Then, if the druntime implementation needs to change again, it won't break old code (like the COM examples!). Better all around.

(Note that this won't break any existing code; using the new template is an opt-in change.)

If this is accepted, I can do a PR to fix the documentation as well.
On Wed, Sep 10, 2014 at 07:13:45AM -0700, Vladimir Panteleev wrote:
> I believe `!()` is unnecessary.

You do still have to instantiate the template. If it wasn't a template, the function would always be in the library and the linker (I think) would try to use it even when you don't want a DllMain at all.