www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D to C++

reply Nick <nickbakkegaard gmail.com> writes:
Is it possible to compile from D to C++?

Explanation:
I do some competition programming and would like to write it in D 
instead of C++ :)
Aug 30 2016
parent reply eugene <egordeev18 gmail.com> writes:
On Tuesday, 30 August 2016 at 13:33:44 UTC, Nick wrote:
 Is it possible to compile from D to C++?

 Explanation:
 I do some competition programming and would like to write it in 
 D instead of C++ :)
maybe will help https://wiki.dlang.org/Calypso
Aug 30 2016
parent reply Nick <nickbakkegaard gmail.com> writes:
On Tuesday, 30 August 2016 at 14:24:22 UTC, eugene wrote:
 On Tuesday, 30 August 2016 at 13:33:44 UTC, Nick wrote:
 Is it possible to compile from D to C++?

 Explanation:
 I do some competition programming and would like to write it 
 in D instead of C++ :)
maybe will help https://wiki.dlang.org/Calypso
That's quite nice, but not what I'm looking for. What Calypso does, as far as I can see, is to make it possible to compile C++ and D together. I'm looking for a compiler that takes in D code and spits out either C or C++ code.
Aug 31 2016
next sibling parent reply Michael <michael toohuman.io> writes:
On Wednesday, 31 August 2016 at 11:43:12 UTC, Nick wrote:
 On Tuesday, 30 August 2016 at 14:24:22 UTC, eugene wrote:
 On Tuesday, 30 August 2016 at 13:33:44 UTC, Nick wrote:
 Is it possible to compile from D to C++?

 Explanation:
 I do some competition programming and would like to write it 
 in D instead of C++ :)
maybe will help https://wiki.dlang.org/Calypso
That's quite nice, but not what I'm looking for. What Calypso does, as far as I can see, is to make it possible to compile C++ and D together. I'm looking for a compiler that takes in D code and spits out either C or C++ code.
I can't imagine that's been done, and I'm not sure it will be high on anybody's list of priorities I'm afraid. A lot of work was done on automating C++ -> D, but converting D, a language intended to replace C++, to C++ itself seems a little backwards. I get why you'd like to use it, but I don't think it's been done, sorry.
Aug 31 2016
parent bachmeier <no spam.net> writes:
On Wednesday, 31 August 2016 at 12:13:38 UTC, Michael wrote:
 I can't imagine that's been done, and I'm not sure it will be 
 high on anybody's list of priorities I'm afraid. A lot of work 
 was done on automating C++ -> D, but converting D, a language 
 intended to replace C++, to C++ itself seems a little 
 backwards. I get why you'd like to use it, but I don't think 
 it's been done, sorry.
Given that you can call D from C++, I don't see the need for such a tool.
Aug 31 2016
prev sibling parent reply Cauterite <cauterite gmail.com> writes:
On Wednesday, 31 August 2016 at 11:43:12 UTC, Nick wrote:
 That's quite nice, but not what I'm looking for.
 What Calypso does, as far as I can see, is to make it possible 
 to compile C++ and D together. I'm looking for a compiler that 
 takes in D code and spits out either C or C++ code.
Your best option would be to use LDC with a C backend: https://www.google.com/search?q=llvm++c+backend No idea how well supported this is, I've never used LLVM myself.
Aug 31 2016
parent Laeeth Isharc <laeethnospam nospam.laeeth.com> writes:
On Wednesday, 31 August 2016 at 12:19:33 UTC, Cauterite wrote:
 On Wednesday, 31 August 2016 at 11:43:12 UTC, Nick wrote:
 That's quite nice, but not what I'm looking for.
 What Calypso does, as far as I can see, is to make it possible 
 to compile C++ and D together. I'm looking for a compiler that 
 takes in D code and spits out either C or C++ code.
Your best option would be to use LDC with a C backend: https://www.google.com/search?q=llvm++c+backend No idea how well supported this is, I've never used LLVM myself.
Julia guys resurrected the C back end for LLVM. Chap here posted about using this to compile D to bitcode to C to JS (last but using emscripten). Even without last stage, doesn't sound a great idea if you are under time pressure, as the whole process is quite fragile. It would be nice to have a robust C backend, even bearing in mind all problems with UB and difficulties one can imagine that might cause.
Aug 31 2016