Automated source translation of C++ to D

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 21 01:00:43 PDT 2014


On 8/20/14, 11:35 PM, Joakim wrote:
> C++ support keeps coming up these days, with Andrei continually
> stressing it as something to work on.  How hard would it to be to write
> a C++->D translator, to allow people to translate C++ libraries to D?
>
> I've been using tools like DStep and looking at libdparse, which seem to
> work very well.  I just translated a C sample app from the Android NDK
> to D, fairly simple stuff like turning -> into ., adding a default in a
> switch statement, rewriting casts from C-style to D-style casts,
> removing the struct label, nothing that couldn't be automated.
>
> I'm sure there's stuff that'd need to be done by hand, but if you can
> automate 97%, that's good enough.  Could this be a viable option for
> many cases?

I think the key here involves clang with hooks + a config file per C++ 
file to translate that instructs the translator how to proceed about 
corner cases (e.g. expand this macro but not this other etc). -- Andrei


More information about the Digitalmars-d mailing list