extern(Windows, "user32.dll")

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 1 02:45:53 PST 2015


On Sunday, 1 February 2015 at 10:40:06 UTC, Benjamin Thaut wrote:
> Please no. Import libraries are the way it was designed

Delphi does without them just fine.

> and it should be used that way.

Why? It seems to me like they are a historical artifact. I don't 
see any merit in the design, none at all. Linux does away with 
them because ld can link against .so, but OPTLINK can't link 
against .dll files (although UniLink can).

> I'm currently implementing D-Dll support for Windows with dmd 
> and without import libraries it will never work.

Why? I'm not suggesting to remove import library support.

> Also what you are proposing could easily be implemented by a 
> library. E.g.
>
> @dllimport("kernel32.dll") extern(Windows) DWORD GetVersion();
> mixin DllImportFunctions;
>
> Where DllImportFunctions would iterate over all symbols in the 
> module, look for the UDA dllimport and then attemp to load the 
> Dll and import the function.

Dynamic loading delays the error until execution time, instead of 
link time, and is slower.


More information about the Digitalmars-d mailing list