Related articles |
---|
C++ -> C Per.Heggtveit@fou.telenor.no (Per Olav Heggtveit) (1997-01-09) |
Re: C++ -> C robison@kai.com (Arch Robison) (1997-01-12) |
Re: C++ -> C morris@CAM.ORG (1997-01-12) |
Re: C++ -> C jsa@edg.com (1997-01-12) |
Re: C++ -> C james@wgold.demon.co.uk (James Mansion) (1997-01-14) |
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 <Per.Heggtveit@fou.telenor.no> 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:
(*(__0oHostreamlsPFR6Hostream_R6Hostream(
(__0oHostreamlsPCc(((struct ostream *)
(&(cout.__b_ostream))),
((char *)"hello, world"))),
(__0FEendlR6Hostream))));
Unfortunately, the target system won't have any of the required
library functions. Such runtime support systems usually come with
compilers.
It would help to know more about your intentions.
>[Is there anything other than cfront? -John]
Yes, the Edison Design Group (http://www.edg.com) produces an
excellent and very carefully crafted C++ front-end package that
includes a C code generator.
Morris
--
Morris Bernstein morris@cam.org
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.