D-Programming-Language/druntime — pull request #706 by adamdruppe (2014-01-10 01:07:43+00:00)
Title: 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.