Automated source translation of C++ to D
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Wed Aug 20 23:48:30 PDT 2014
On 21/08/14 08:35, 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 it will be quite difficult. There are probably many cases of C++
code where there is no direct translation in D. libclang, which DStep
uses, is probably not enough to do a complete source translation of C++.
That means using the C++ Clang API's which are unstable in written in C++.
C is completely different. D was basically designed to allow to easy
translate C to D. If a C syntax compiles in D it's supposed to have the
same semantics as in C.
It might be possible. As a start you could help out with DStep. Starting
to add support for C++ for example.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list