Load dynamic libraries with no hand-written bindings!
Paul Backus
snarwin at gmail.com
Wed Sep 7 13:23:51 UTC 2022
On Wednesday, 7 September 2022 at 05:29:31 UTC, Andrej Mitrovic
wrote:
> On Tuesday, 6 September 2022 at 16:50:16 UTC, Paul Backus wrote:
>> Haven't tested, but I think you may be able to simplify this
>> by replacing
>>
>> FuncType!(__traits(getMember, Module, member))
>>
>> with
>>
>> typeof(&__traits(getMember, Module, member))
>>
>> ...which would let you eliminate the `FuncType` template
>> entirely.
>
> Already tried that, but it doesn't work. Maybe it's just a bug
> in the backend.
I'd say it's definitely a bug of some kind. This simplified
example worked for me:
```
--- lib.c
int f(int x) { return x + 1; }
--- app.d
import lib;
typeof(&__traits(getMember, lib, "f")) fptr;
pragma(msg, typeof(fptr)); // extern (C) int function(int x)
```
More information about the Digitalmars-d
mailing list