extern(Windows, "user32.dll")

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 1 02:34:05 PST 2015


On 1/02/2015 11:26 p.m., Vladimir Panteleev wrote:
> The Delphi programming language allows specifying the DLL name right on
> the declaration of extern symbols:
>
> function GetVersion: DWORD; stdcall; external 'kernel32.dll';
>
> I would like to suggest adding something similar to D:
>
> extern(Windows, "kernel32.dll") DWORD GetVersion();
>
> Rationale:
>
> This absolves the need for import libraries.
>
> * Import libraries are a major and unnecessary pain in the neck when
> using DLLs of any kind.
>
> * Import libraries may need conversion from COFF format to OMF format
> with a tool which is not included with D (coffimplib).
>
> * Import libraries can *sometimes* be created from the DLL using implib,
> but this does not always work, depending on the calling convention and
> its mangling.
>
> * Name mangling mismatches are difficult to diagnose.
>
> * Import libraries cannot be used with tools such as "rdmd", except via
> pragma(lib).
>
> Any thoughts? DIP or not?

How about:

extern(System, "mylibrary"):

That way it'll be a bit more cross platform'ish.


More information about the Digitalmars-d mailing list