extern(Windows, "user32.dll")

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 1 05:27:01 PST 2015


On Sunday, 1 February 2015 at 12:09:56 UTC, Benjamin Thaut wrote:
> http://wiki.dlang.org/DIP45

OK, so I understand it's mostly about D DLLs.

This bit though:

"In an import library the original symbol is redifined as 
trampoline that simply dereferences the _imp_ pointer to the DLL 
function. Thus calling an exported function will be compatible 
with both import libraries and static libraries, in the later 
case without indirection."

Is this different from how things are now?

Also, how does this conflict with my proposal? If the compiler 
knows the function to be in a DLL, it can elide generating a 
trampoline at all, and reference the __imp__ symbol directly.

> Yeah, but the problem is, that as soon as you do that you are 
> limiting yourself to DLL versions of that library. If you for 
> example want to link curl statically this will no longer work. 
> And in my opinion its bad to hardcode in the sourcecode if your 
> expecting a static or shared version of the library.

That's a good point. It would be possible to define my proposal 
so that it would be easy to switch between the two with a 
-version switch. On one hand, you trade one compiler switch 
(static.lib or import.lib) for another (-version=static). On the 
other hand, for the DLL case, you skip the headache of import 
libraries.


More information about the Digitalmars-d mailing list