More automated interfacing of D with C codebases

Brad Lanam brad.lanam.comp at -NOSPAM-gmail.com
Mon Oct 22 12:48:50 PDT 2012


On Monday, 22 October 2012 at 19:12:46 UTC, Jacob Carlborg wrote:
> On 2012-10-22 20:38, Brad Lanam wrote:
> I prefer the approach I took when I created DStep, it uses 
> libclang. The tool can parse all C(++) and Objective-C(++) code 
> that clang can. Although it currently won't generate code for 
> everything, at least it doesn't choke any code.
>
> I also get all bug fixes and new languages features for free 
> when they're added to clang.
>
> No need to create interface files.

Nothing wrong with that.
I had different goals -- portability and legacy systems.  My tool 
is all bourne shell and awk.  There aren't many systems it does 
not work on (e.g. ULTRIX shell runs out of memory).

I should also state my tool was written as a build configuration 
tool (like autoconf/iffe/dist), not a conversion tool.  SWIG is 
better supported, faster and supports more languages.

If you need to write code that runs on multiple systems and works 
with low level system calls (rpc, et.al.), my tool might be a 
better choice.

This sort of thing (from the D compiler):

#if __sun
#include        <alloca.h>
#endif

Is nuts.  I thought everyone had gotten away from that sort of 
thing (it died out in the mid-eighties!), but I still see it in 
code everywhere.  The system should be tested for its 
capabilities and what it has available, not whether it is a sun 
machine.

   -- Brad



More information about the Digitalmars-d-learn mailing list