www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Transforming a C/C++ project to D

reply Russel Winder <russel winder.org.uk> writes:
I may have missed something in Google searches but…

I am looking at a GTK+2 project that was originally C, got transformed
somewhat (and a bit badly) into a mix of C and C++. I can either move it
the whole thing to C++14 or try to turn it into a D code. Revolutionary
change is likely out of the question simply because it is a bigish
project and too big an "elephant task". If however it is possible to
incrementally move parts of the whole to D that is much more likely to
happen.

Has any done this incremental move type thing before and had success?

Thanks.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Mar 26 2014
parent reply Jacob Carlborg <doob me.com> writes:
On 2014-03-26 17:17, Russel Winder wrote:
 I may have missed something in Google searches but…

 I am looking at a GTK+2 project that was originally C, got transformed
 somewhat (and a bit badly) into a mix of C and C++. I can either move it
 the whole thing to C++14 or try to turn it into a D code. Revolutionary
 change is likely out of the question simply because it is a bigish
 project and too big an "elephant task". If however it is possible to
 incrementally move parts of the whole to D that is much more likely to
 happen.
Sure, it should be possible to incrementally move a project from C to D. It depends a bit on how the project structure looks like, but you should be able to port object files one at the time to D. Then link it with the rest of the object files. You can use Adam D. Ruppe's tool dtoh, currently being reviewed [1], to create C bindings for D code. You can also use DStep [2] to create D bindings for the C code. [1] http://forum.dlang.org/thread/lgspgg$2i8l$1 digitalmars.com [2] https://github.com/jacob-carlborg/dstep -- /Jacob Carlborg
Mar 26 2014
parent reply Andrew Edwards <ridimz yahoo.com> writes:
On 3/26/14, 1:51 PM, Jacob Carlborg wrote:
 You can use Adam D. Ruppe's tool dtoh, currently being reviewed [1], to
 create C bindings for D code. You can also use DStep [2] to create D
 bindings for the C code.

 [1] http://forum.dlang.org/thread/lgspgg$2i8l$1 digitalmars.com
 [2] https://github.com/jacob-carlborg/dstep
For the rest of us who do not use Tango, will DStep ever offer an option for use with just the phobos?
Mar 26 2014
parent Jacob Carlborg <doob me.com> writes:
On 2014-03-26 19:38, Andrew Edwards wrote:

 For the rest of us who do not use Tango, will DStep ever offer an option
 for use with just the phobos?
No, not unless someone else does the work. Although I don't see the problem. Pre-compiled binaries are available or it can compile it with Dub, which will handle all dependencies automatically. -- /Jacob Carlborg
Mar 26 2014