D and C APIs

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 05:24:48 PST 2016


On Tue, 2016-01-12 at 11:05 +0000, John Colvin via Digitalmars-d wrote:
> […]
> 
> What's so hard about writing a few function prototypes, aliases 
> and enums? It's annoying that we have to do it, but compared to 
> writing the rest of a project it's always going to be a tiny 
> amount of work.

I started there but gave up quite quickly as there are two levels of
API here, both of which are needed to use the higher-level API as it
refers directly to low-level structs and stuff.

There is the kernel device drivers level, which defines the low-level
API, and then there is libdvd5 which provides a (slightly) higher C API
– with all the idiocies of a C API for doing high-level library
programming :-(

I have found a Rust wrapper of the kernel API, but that would mean
writing all the libdvbv5 equivalent myself before writing the
application code. There is no equivalent D version and certainly no
easy way of wrapping libdvbv5 in D without it. Go has problems with C
APIs and no sensible GTK3 wrapper.

> For a lot of projects you can only bind what you actually need, I 
> often just pretend that I have already written the bindings then 
> write whatever lines are necessary to get it to compile!

The problem is that this is easy in C++ for a C API, but not for D or
Rust using the same C API. C++ can use the C stuff directly, D and Rust
need an adaptor.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

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


More information about the Digitalmars-d mailing list