Programming Windows D Examples are now Online!
Andrej Mitrovic
andrej.mitrovich at gmail.com
Tue Jun 21 11:32:55 PDT 2011
On 6/21/11, Walter Bright <newshound2 at digitalmars.com> wrote:
> On 6/20/2011 10:11 PM, Andrej Mitrovic wrote:
>> Btw, would it be good idea to link this somewhere on the homepage?
>
> Sure! Wanna generate a pull request?
>
Yeah I'll cook something up and make a pull.
Btw, std.c.windows.windows and the WindowsAPI bindings clash when used
together. The root of the problem is type definitions like these:
typedef void* HINSTANCE;
The problem is that both bindings create this typedef, and the
compiler treats them as separate types. From what I recall I've tried
to compile something like this before (this is just a snippet):
import win32.windef;
import core.sys.windows.dll;
extern (Windows)
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
{
switch (ulReason)
{
case DLL_PROCESS_ATTACH:
g_hInst = hInstance;
dll_process_attach( hInstance, true );
break;
case DLL_PROCESS_DETACH:
dll_process_detach( hInstance, true );
break;
case DLL_THREAD_ATTACH:
dll_thread_attach( true, true );
break;
case DLL_THREAD_DETACH:
dll_thread_detach( true, true );
break;
default:
}
return true;
}
However this won't work. dll_process_attach() can't be called with the
`hInstance` argument because it's defined as a typedef in
`win32.windef`, while dll_process_attach has the parameter defined as
a typedef somewhere in `core.windows` or a similar module.
I don't know whether it is planned to incorporate the WinAPI bindings
into Phobos/Druntime, there's at least 2.5 megs of code in prototypes
and I'm not sure about the license (it's based on the MinGW headers).
std.c.windows.windows is already growing as people need to call more
API functions (just recently a bunch of prototypes were added for
std.registry). It seems odd having to waste time writing function
prototypes when this was already done long ago in the WinAPI bindings.
More information about the Digitalmars-d-announce
mailing list