3

Possible Duplicate:
Code convert from C++ to C

This is the dilemma. I have software that will be 10 times easier to maintain in C++ than C. This code will run on various platforms (on the PC and embedded systems of various types). C++ is naturally a better language for this project because I have components that must be switched in and out to accommodate the various platforms that it will be running on. Abstract classes, polymorphism, really really helps.

The problem is that some embedded systems does not have a C++ compiler, only C. Now I could rewrite the software in C but this is problematic since the software is always evolving and maintaining a C branch and C++ branch will be costly. What I want instead is something, or some method, of developing the software in C++ and then when necessary, I can either throw the code into some kind of magical converter to get C code. Or maybe I can achieve this with compiler flags.. sounds messy but seems possible. The second option, which I really really want to avoid, is to bite the bullet and maintain the code in C.

Any solutions?

Community
  • 1
  • 1
umps
  • 1,119
  • 4
  • 15
  • 25
  • 2
    Is this basically a dup of http://stackoverflow.com/questions/737257/code-convert-from-c-to-c? – Andrew White Dec 10 '10 at 04:51
  • 1
    I don't know enough about this for a real answer but isn't this the way the first C++ compilers worked? They first compiled to C, then the C compiler would compile down to machine code. Maybe you could do something similar. – D.C. Dec 10 '10 at 05:00
  • 1
    Which embedded sys are you talking about ? Most of the modern ones have a C++ compiler. Also if you are working on a project how can you be sure that online converters give a quality o/p ? You have a very fugly solution in mind. We dont deal with magical converters lol – Reno Dec 10 '10 at 05:08

1 Answers1

0

Comeau C++ generates C code.

dan04
  • 87,747
  • 23
  • 163
  • 198