0

As the topic states, I'm looking for a C++ to C converter as I have some C++ code that i need ported to C and i'm not confident in my re-writing skills (code in question is https://github.com/tuanpmt/espduino) and the source code is fairly uncommented.

People asking similar questions have stated they want the code to be readable after the conversion, THIS IS NOT IMPORTANT TO ME, ie if the code can compile and run (it's reasonably simple C++ just excessively tedious to do it manually as I see it right now) THAT'S ALL THAT MATTERS.

Since I want it to remain open-source (I am aware of Comeau's compiler, however a) the site is a mess right now and b) I'm cheap) and LLVM is the only viable solution I've seen around, HOWEVER the documentation/examples i have seen for C++->...->C is quite hard to follow, as well as having issues with several different releases.

If someone can recommend an alternative OR has previous experience doing this OR can explain doing this in LLVM in greater detail than copy-pasting poorly explained tutorials, then that would be fantastic.

  • That's ~500 lines of code to "convert", it's maybe an afternoon worth of work... – Matteo Italia Dec 01 '15 at 23:55
  • 1
    @MatteoItalia But if you do it by hand, you'll need to maintain/develop both versions. – Baum mit Augen Dec 01 '15 at 23:57
  • @BaummitAugen: yeah, but finding anything other than g++ being able to compile Arduino libraries (freestanding, AVR-specific, bare-metal stuff full of GNU-isms and the like) is going to be tough. Honestly, I wouldn't even try to use llvm-g++ + decompile to C (as suggested in the linked question) for this kind of stuff, even if it produced something (and it's going to be though) I wouldn't trust the result anyway. – Matteo Italia Dec 02 '15 at 00:08
  • Also: @Mentalmachine, you should explain what you are doing: Arduino is already all C++, what's the point of trying to convert an Arduino-specific library to C? – Matteo Italia Dec 02 '15 at 00:09
  • @MatteoItalia: cheers for all your input, much appreciated. I'm on low levels of sleep atm, so please bear with me, but i have a PIC microprocessor i want to port the espduino C++ code to. I amaware i have to strip out and replace some of the arduino-specific stuff proper C/C++. My entire thought process was to rewrite the "espduino" to proper C++, use LLVM or equivalent to get it to C, then try and get it to run on the PIC. I'm considering this mainly because I can't find any advice on actual C++ to C rewriting, and i'm not confident i can rewrite it myself right now. – Mental machine Dec 02 '15 at 00:33
  • PIC is a completely different MCU family. Not only the CPU is very different, but - more important - it has completely different peripheral modules. The by far largest part for porting would be to adopt the low-level routines. Instead of porting, a rewrite is likely the easier way to go. Even more, as the PIC might require some different approaches than ATmega. – too honest for this site Dec 02 '15 at 02:34

0 Answers0