Example of using C API from D?

rikki cattermole rikki at cattermole.co.nz
Sun Sep 2 13:00:27 UTC 2018


On 03/09/2018 12:52 AM, Russel Winder wrote:
> I am rewriting a C++ program in D, but need to access a C library that
> has no D binding: this is a GtkD based program which has a Pango
> binding, but Pango doesn't offer the information I need, that is hidden
> in the underlying Fontconfig C API.
> 
> I could create a complete D binding for Fontconfig using the GIR files
> but that seems a bit over the top.
> 
> Can anyone point me at an example of a D program using a C API that has
> structs, enums and functions so I can see if I just hack enough for my
> use or go on to the full binding activity.
> 

You don't need to create a complete binding for something to use a 
subset of it.

Writing up a Derelict style binding is easy enough since e.g. SharedLib 
struct handles most of the work (from util package).

https://github.com/DerelictOrg/DerelictUtil/blob/master/source/derelict/util/sharedlib.d#L118


More information about the Digitalmars-d-learn mailing list