Hi,
I'm sure this question has been asked a few times before
But I'm currently looking at something that will convert Cpp code to D

I've recently setup a proof of concept demo which uses mbed for an embedded LPC1769 Arm board This is just a test, but I've recently managed to get debugging working across both C and D files at the same time. This means single stepping code on a remotely attached Arm board in VSCode, while being able to inspect registers with an svd file
https://github.com/grbd/GBD.Dlang.MbedBlinkyTest

There's a couple of outstanding things at the moment though

The first is the use of BetterC, although from what I can tell DMD now has support for a minimal runtime feature as part of 2.079.0
https://dlang.org/changelog/2.079.0.html#minimal_runtime
so hopefully when this makes it's way into LDC I can then make use of it for an Arm MCU for creating class's without the full runtime.
https://github.com/ldc-developers/ldc/pull/2587

These were also mentioned in a separate thread.
  * https://bitbucket.org/timosi/minlibd
  * https://github.com/JinShil/stm32f42_discovery_demo
  * https://github.com/kubo39/stm32f407discovery


The second is that mbed uses C++ class's for it's API
most of this is just headers such as DigitalOut.h
https://github.com/ARMmbed/mbed-os/blob/master/drivers/DigitalOut.h
So ideally I've been looking for something that can translate those headers into Dlang so they can be used there instead.

* The first two utils I've found were DStep and htod, however they seem to only hand C
    https://github.com/jacob-carlborg/dstep

  * I discovered some examples of libraries over here
    https://github.com/D-Programming-Deimos

  * There's CPP2D but the last update was around 2016
    https://github.com/lhamot/CPP2D

* Calypso seems to be a Fork of LDC, but I think it might be a while before 2.079.0 makes it in.
    https://github.com/Syniurge/Calypso

One possibility I might look into is a D backend for CppSharp if I can figure it out, since I'm familiar with C#.
  * https://github.com/mono/CppSharp

I was wondering if there are any other ways that are known about for translating C++ into D, or accessing C++ libraries.

Many Thanks
Richard

Reply via email to