DIP 45 - approval discussion
Walter Bright
newshound2 at digitalmars.com
Mon Nov 18 01:22:55 PST 2013
On 11/17/2013 9:25 PM, Daniel Murphy wrote:
> "Walter Bright" <newshound2 at digitalmars.com> wrote in message
> news:l6c7gt$27fc$1 at digitalmars.com...
>>>
>>> Right, I was saying the indirection still exists.
>>>
>>>
>>
>> No, not really, at least not on Windows. Try calling a function in the
>> Windows API and disassemble it. You'll see a direct call.
>
> You sure about that?
>
> src:
>
> import core.sys.windows.windows;
>
> void main()
> {
> auto x = GetModuleHandleA(null);
> }
>
> obj:
>
> __Dmain PROC NEAR
> ; COMDEF __Dmain
> push 0 ; 0000 _ 6A, 00
> call dword ptr [__imp__GetModuleHandleA at 4] ; 0002 _ FF. 15,
> 00000000(segrel)
> xor eax, eax ; 0008 _ 31. C0
> ret ; 000A _ C3
> __Dmain ENDP
>
>
> exe:
>
> ?_0072 LABEL NEAR
> push 0 ; 00402010 _ 6A, 00
> call dword ptr [?_0067] ; 00402012 _ FF. 15,
> 00401794(d)
> xor eax, eax ; 00402018 _ 31. C0
> ret ; 0040201A _ C3
>
>
Try this:
extern (Windows) int GetModuleHandleA(char*);
void main()
{
auto x = GetModuleHandleA(null);
}
and it compiles and links and runs. No indirection (in the object file, the
indirection is supplied by linker, triggered by an impdef record in
kernel32.lib). The "export" isn't actually needed.
More information about the Digitalmars-d
mailing list