ssll - simple shared library loader
aldacron at gmail.com
Mon Jan 6 04:32:25 UTC 2020
On Sunday, 5 January 2020 at 23:23:48 UTC, Oleg B wrote:
Nice work! One thing I would recommend, though, is that you not
bake in extern(C). Some libraries require extern(System) (because
they're stdcall on Windows and cdecl everywhere else).
There's also the issue with the Windows stdcall name-mangling
scheme in 32-bit libraries, where the symbol name incorporates
the size of the function parameters. Some stdcall libraries (like
OpenGL) are configured to compile with the unmangled names, but
others (like FreeImage) are not and require transforming the
symbol name into the mangled form.
So to be robust, you'll want to implement support for both into
> It's analog of bindbc, but without need write boilerplate code.
> May be bindbc is designed for another cases, but I don't
> understand need writing triple definition for one function
> (pointer, loading, wrap-function).
There are only two declarations required for the dynamic bindings
in BindBC: an alias and a pointer. And of course the loader is
separate. The reason is historical. When I was working on the
earliest version of Derelict back in 2004, we didn't have all the
fancy compile-time features we have now. I (and a couple of
contributors) tried doing it by declaring the function pointers
without aliases, but we ran into a couple of issues and settled
for taking the alias + pointer approach. (It's been so long that
I can't recall what the issues were).
In the 4th iteration of Derelict (the bindings in DerelictOrg on
github), I experimented with UDAs and single function
declarations that I could generate static and dynamic bindigs
with. But I was still mixing in the alias and pointer
declarations for the dynamic bindings and could never figure out
a way to distinguish between them during introspection. I posted
about it here on the forums and no one had an answer, so I gave
So bindbc is implemented the way it is because that's the way
I've done it for almost 16 years.
More information about the Digitalmars-d-announce