c++ to c

H

Horacius ReX

Hi,

I have to convert a C++ program, not very complicated, to C. What is
the best automatic approach appart from LLVL and Comeau ? Do you
really know some more ? :)
 
D

dj3vande

Hi,

I have to convert a C++ program, not very complicated, to C. What is
the best automatic approach appart from LLVL and Comeau ? Do you
really know some more ? :)

Hire a C programmer. It will make everyone's life easier if the C
programmer you hire also understands C++.

(What are you really trying to do?)


dave
 
H

Horacius ReX

- as I said, I have to port a C++ program to another architecture
where there is only a C compiler (please, this can not be avoided)
- want to work ? what are your honoraries ? :)
 
I

Ian Collins

Horacius ReX wrote:

Please don't top post

Or quote signatures.
- as I said, I have to port a C++ program to another architecture
where there is only a C compiler (please, this can not be avoided)
- want to work ? what are your honoraries ? :)

If you want to be able to maintain it, either re-write it or see if
Comeau supports the target.
 
J

joecook

Hi,

I have to convert a C++ program, not very complicated, to C. What is
the best automatic approach appart from LLVL and Comeau ? Do you
really know some more ? :)

Why do you want to do this? Is it simply because you are integrating C
++ code into a C project? Could you use "extern C" calls and minimize
your work?

Joe C
 
P

Pascal J. Bourguignon

Horacius ReX said:
Horacius ReX wrote:

Please don't top post


as I said, I don't want to use Cormeau, which seems awful to me

In anycase, if the program exploited C++ specific features, it'll be a
lot of work. I don't know up to date C++ to C translators.

If it had been more than ten years ago, you could have used CFront,
the original C++ implementation, to produce a C source from a C++
source. But since then a lot of features have been added to C++.


If it's not very complicated, then a C programmer who knows C++ shall
be able to do a good job at translating it.
 
O

osmium

Pascal J. Bourguignon said:
In anycase, if the program exploited C++ specific features, it'll be a
lot of work. I don't know up to date C++ to C translators.

If the program makes much use of the STL it might be a much better idea to
start over; extract the problem definition and write a C program to solve
that problem.
 
T

Tony

Greg Comeau said:
This is exactly one of the possibilities that Comeau (me) can do
with Comeau C++ for you. And this way, your code stays C++,
and you leverage off of the technology you already have
(above mentioned C compiler, etc).
--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

There is a thread in comp.lang.c called "C++ to C" which currently goes as
follows:

"> Look Richard, C++ is just syntactic sugar around C.
Proof:

Comeau C++ compiler works by generating C, not assembly.

And the fact that it is one of the best C++ compilers around
proves that you can write in C ANYTHING you can write in C++.

That's misleading or at least incorrect because Comeau generates highly
platform-specific C. Meaning that it takes advantage of compiler-specific
extensions to the C language and OS-specific extensions also I think."


I added the last post above. Do I have it right? (I have read the
descriptions of Comeau compilers a few times over the years, so that's what
sticks in my mind). If not, I'll go change it (or you can).

Tony
 
J

James Kanze

"Greg Comeau" <[email protected]> wrote in message

[...]
There is a thread in comp.lang.c called "C++ to C" which
currently goes as follows:
"> Look Richard, C++ is just syntactic sugar around C.
That's misleading or at least incorrect because Comeau
generates highly platform-specific C.

It's a downright lie, or else the person who wrote it is
incredibly stupid. Obviously, you can write in C anything you
can write in C++, since both languages are Turing complete. But
Comeau (and before that CFront) are not "front-ends" or wrappers
or preprocessors for C. They're full fledged compilers, which
use C (or have an option to use C) as an intermediate language.
Much like the compilers of some Lisp dialects, or Mercury (a
Prolog relative) or a lot of othe experimental languages use C
as an intermediate language. By the same reasoning, C and
Fortran are just syntactic sugar around RTL (GCC's intermediate
language).
 
H

Horacius ReX

Why do you want to do this?  Is it simply because you are integrating C
++ code into a C project?  Could you use "extern C" calls and minimize
your work?

Joe C

no, unfortunately
 
H

Horacius ReX

This is exactly one of the possibilities that Comeau (me) can do
with Comeau C++ for you.  And this way, your code stays C++,
and you leverage off of the technology you already have
(above mentioned C compiler, etc).
--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==>    http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

i think i said clearly that i do not want to use cormeau
 
D

dj3vande

i think i said clearly that i do not want to use cormeau

You still haven't given a good reason why not.

If you really want it translated to C without using tools to do it
automatically, stop arguing about it on usenet and hire a C
programmer.
But if what you really want is to be able to run existing C++ code on a
platform that only has a C compiler, a tool that automates the process
is the right way to accomplish that, especially if the C version will
need to incorporate maintenance changes made to the C++ version in the
future. (Paying Comeau to do a custom port for your back-end, if one
doesn't already exist, is probably cheaper in the long run than paying
a C programmer to maintain a parallel version.)


dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top