Wrapping multiple extern (C) declarations in a template
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Dec 13 14:54:34 PST 2014
On 12/14/2014 4:03 AM, aldanor wrote:
> However, it wouldn't be
> possible to retain the same function names since they've been imported
> to the namespace (it's then also not possible to extern them as private
> initially since then you won't be able to import/wrap them in a
> different module). Hence the idea of mixing the wrapping template in the
> initial .d header.
>
Assuming the C library can be compiled as a shared library, you can
load it dynamically. This will allow you to call the function names
whatever you want. Declare them all as function pointers, import them
privately in your wrapper module and give your wrapper functions names
matching the C API.
More information about the Digitalmars-d-learn
mailing list