Re: C++ -> C

morris@CAM.ORG (Morris Bernstein)
12 Jan 1997 11:47:26 -0500

          From comp.compilers

Related articles
C++ -> C (Per Olav Heggtveit) (1997-01-09)
Re: C++ -> C (Arch Robison) (1997-01-12)
Re: C++ -> C morris@CAM.ORG (1997-01-12)
Re: C++ -> C (1997-01-12)
Re: C++ -> C (James Mansion) (1997-01-14)
| List of all articles for this month |

From: morris@CAM.ORG (Morris Bernstein)
Newsgroups: comp.compilers
Date: 12 Jan 1997 11:47:26 -0500
Organization: Communications Accessibles Montreal, Quebec Canada
References: 97-01-064
Keywords: C++, C, translator

Per Olav Heggtveit <> wrote:
>I need to convert C++ code to C code (semi)automaticly.
>Has anyone good or bad experience with a certain compiler/tool
>for doing this?

In general, source to source translation systems have two critical
problems. Such translators usually produce highly unreadable output.
If you want to be able to maintain the translated code afterwards,
just forget it. You're almost certainly going to be better off just
reimplmenting your software.

The second problem is the runtime support. For example, if you wanted
to translate
cout << "hello, world" << endl;
into C to run it on another system that has no C++ compiler, a C++ to C
translator would be happy to convert it to a sequence of function
calls, something like this:
(__0oHostreamlsPCc(((struct ostream *)
((char *)"hello, world"))),
Unfortunately, the target system won't have any of the required
library functions. Such runtime support systems usually come with

It would help to know more about your intentions.

>[Is there anything other than cfront? -John]

Yes, the Edison Design Group ( produces an
excellent and very carefully crafted C++ front-end package that
includes a C code generator.

Morris Bernstein

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.