For Programmers: Free Programming Magazines  


Home > Archive > Compilers > February 2008 > translating oo features to C









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author translating oo features to C
dvanguard@gmail.com

2008-02-01, 7:45 pm

I was wondering if there are any open source compilers out there to
translate the C++/Java/C#-like object model to C. Thanks,

David

Claudio Saavedra

2008-02-04, 7:51 pm

El jue, 31-01-2008 a las 08:19 -0800, dvanguard@gmail.com escribiC3:
> I was wondering if there are any open source compilers out there to
> translate the C++/Java/C#-like object model to C. Thanks,


There is Vala, which translates Vala source code (similar to C#) to C,
by using GObject.

http://live.gnome.org/Vala

Claudio

--
Claudio Saavedra <csaavedra@alumnos.utalca.cl>

Hans-Peter Diettrich

2008-02-04, 7:51 pm

dvanguard@gmail.com wrote:

> I was wondering if there are any open source compilers out there to
> translate the C++/Java/C#-like object model to C.


What are your expectations?

C++ started as a preprocessor, converting C++ source code into C. You
may still find such a tool in some archive.

With regards to Java/C#, both have have automatic garbage collection.
Even if it's possible to add garbage collection to an application, I
doubt that the results will be impressive, without major (automatic)
changes to the original program structure.

DoDi

Calin Dumitrescu

2008-02-06, 10:17 pm

On Jan 31, 6:19 pm, dvangu...@gmail.com wrote:
> I was wondering if there are any open source compilers out there to
> translate the C++/Java/C#-like object model to C. Thanks,
>
> David


You can use LLVM for C++ to C translation. The result is not exactly
human readable though. Quoting from the FAQ:

==CUT==

Can I use LLVM to convert C++ code to C code?

Yes, you can use LLVM to convert code from any language LLVM supports
to C. Note that the generated C code will be very low level (all loops
are lowered to gotos, etc) and not very pretty (comments are stripped,
original source formatting is totally lost, variables are renamed,
expressions are regrouped), so this may not be what you're looking
for. However, this is a good way to add C++ support for a processor
that does not otherwise have a C++ compiler. ==CUT==


The good thing is that this is not a shoddy source translator. The
input is compiled with GCC (a real compiler) to intermediate
representation (a virtual instruction set) which is then translated to
C.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com