Proof of concept: automatically import C header files

Timothee Cour thelastmammoth at
Tue Jul 16 20:49:19 PDT 2013

On Tue, Jul 16, 2013 at 8:05 AM, Dicebot <public at> wrote:

> On Tuesday, 16 July 2013 at 14:15:55 UTC, Jacob Carlborg wrote:
>> Made a proof of concept to automatically parse, translate and import C
>> header files in D using DStep. DMD is linked against DStep and does not
>> start new process to make the translation.
> While this a relatively common request, I don't think such stuff belongs
> to compiler. It creates extra mandatory dependencies while providing little
> advantage over doing this as part of a build system.
> So far I am perfectly satisfied with invoking dstep from a Makefile.

I agree that this stuff doesn't belong to compiler, however Makefiles suck
(not even portable) and build systems should be avoided whenever a more
integrated solution exist.

So how about a library solution instead, which doesn't require compiler

import parse_c_header_importer;
void main () { foo();}

There are several options:

mixin(parse_c_header(import("foo.h"))); => defines D symbols for everything
in foo.h (excluding things included by it)

mixin(parse_c_header(import("foo.h"),recursive)); => same, but recursively
(probably not very useful, but could be useful if we instead used .i swig
interface files.

The least wasteful:
void foo();
int bar();
=> only defines symbols provided

(I've proposed this syntax in an earlier thread)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digitalmars-d mailing list