Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 26, 2017 Extern C and Symbol Mangling | ||||
---|---|---|---|---|
| ||||
Hi, I'm trying to link against a DLL which exports a bunch of C functions. The issue is: C symbols do not have underscore prefix in Windows, but DMD sticks underscore in front of the symbol name. For example: `extern(C) void Foo()` becomes `_Foo`. Is there a way to disable that underscore? Thanks in advance, -- Oleksii |
May 26, 2017 Re: Extern C and Symbol Mangling | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oleksii | On Friday, 26 May 2017 at 12:49:27 UTC, Oleksii wrote:
> Hi,
>
> I'm trying to link against a DLL which exports a bunch of C functions. The issue is: C symbols do not have underscore prefix in Windows, but DMD sticks underscore in front of the symbol name. For example: `extern(C) void Foo()` becomes `_Foo`.
>
> Is there a way to disable that underscore?
Use extern(Windows), or the more general extern(System), which will expand to either extern(C) or extern(Windows), depending on the OS you target.
|
May 26, 2017 Re: Extern C and Symbol Mangling | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | On Friday, 26 May 2017 at 12:51:20 UTC, Stanislav Blinov wrote:
> On Friday, 26 May 2017 at 12:49:27 UTC, Oleksii wrote:
>> Hi,
>>
>> I'm trying to link against a DLL which exports a bunch of C functions. The issue is: C symbols do not have underscore prefix in Windows, but DMD sticks underscore in front of the symbol name. For example: `extern(C) void Foo()` becomes `_Foo`.
>>
>> Is there a way to disable that underscore?
>
>
> Use extern(Windows), or the more general extern(System), which will expand to either extern(C) or extern(Windows), depending on the OS you target.
Great thanks, it helped in deed. I still wonder why, since I expected `extern(Windows)` to be equal to `__stdcall`, which should have produced a mangled name `?Foo@0` instead of `Foo`, and I can clearly see in the Dependency Walker, that there's no such symbol in the DLL.
|
May 27, 2017 Re: Extern C and Symbol Mangling | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oleksii | On Friday, 26 May 2017 at 12:49:27 UTC, Oleksii wrote: > Hi, > Call methods and property C++ from D. Interface C++ and D and their interaction. https://pp.userapi.com/c636630/v636630885/4657a/07wCn5hbHHo.jpg https://www.youtube.com/watch?v=HTgJaRRfLPk |
Copyright © 1999-2021 by the D Language Foundation