Example of using C API from D?

Russel Winder russel at winder.org.uk
Sun Sep 2 17:07:37 UTC 2018


On Mon, 2018-09-03 at 01:00 +1200, rikki cattermole via Digitalmars-d-
learn wrote:
> 
[…]
> You don't need to create a complete binding for something to use a 
> subset of it.

True, but all too often you find there are so many interdependencies of
names, you end up binding most of the API. I tried fiddling with
Fontconfig using Python which has no binding and was able to hack up
just enough using CFFI to get things working. So I think in this case a
subset for the application is feasible – as opposed to creating a
complete binding. 

> 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

I am not convinced this is a good approach since you do not get the
signatures at compile time. The advantage of a binding, or subset of a
binding is that you get full compiler support.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180902/a2219f8d/attachment.sig>


More information about the Digitalmars-d-learn mailing list