D and C APIs

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 04:56:26 PST 2016


On Tuesday, 12 January 2016 at 11:05:38 UTC, John Colvin wrote:
> On Tuesday, 12 January 2016 at 10:43:40 UTC, Russel Winder 
> wrote:
>> On Tue, 2016-01-12 at 08:12 +0000, Atila Neves via 
>> Digitalmars-d wrote:
>>> On Monday, 11 January 2016 at 17:25:26 UTC, Russel Winder 
>>> wrote:
>>> > [...]
>>> 
>>> This is the kind of thing I wrote reggae for. CMake is an 
>>> alternative, but I'd rather write D than CMake script.
>>
>> CMake scripts are hideous in that the language is like nothing 
>> else, other than perhaps m4 macros. They should have used 
>> Lisp. Or Python.
>>
>> I must try Reggae at some stage, but for now I need to 
>> progress this Me TV rewrite. D and Rust provide so many 
>> barriers to effective use of a C library, that I am resorting 
>> to using C++. Yes you have to do extra stuff to avoid writing 
>> C code, but nowhere near the amount you have to to create D 
>> and Rust adaptors.
>
> 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.

What's hard is that the function prototypes usually use/need:

. macros
. struct definitions

Without a C preprocessor it's extremely hard to bind to any 
non-toy C API. It's the only reason I'd consider using C++ 
instead of D. But only after trying DStep first.

Atila


More information about the Digitalmars-d mailing list