473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Translate C++ to C

Hi all,
Are there any version of g++ that translates C++ to C. or any open
source compiler to do this.

Thanks
Ganesh

Nov 14 '05 #1
6 10147
Hi,
C++ was created because C and other procedure-oriented languages
could not address the complex problems that are present in real life.

So the question of translating C++ code to C is absurd. You have to
rewrite the code completely and that would be no small feat.

Regards,
Karthik.

Nov 14 '05 #2
Hello,

ka**********@gmail.com <ka**********@gmail.com> wrote:
C++ was created because C and other procedure-oriented languages could
not address the complex problems that are present in real life.
Ah, so C cannot be used to write complex problems of real life? I
believe you should not shout this here in this newsgroup. ;-)
So the question of translating C++ code to C is absurd. You have to
rewrite the code completely and that would be no small feat.


But remember: The first versions of C++ were implemented as a
preprocessor only, which produced a C source which had to be compiled by
a C compiler afterwards. Thus, such beasts do exist (but I do not know
if they exist for recent C++ versions).

Anyway, I do not know if that C code is very human readable afterwards.

Regards,
Spiro.

--
Spiro R. Trikaliotis http://cbm4win.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/
Nov 14 '05 #3
In article <11*********************@l41g2000cwc.googlegroups. com>,
ka**********@gmail.com <ka**********@gmail.com> wrote:
C++ was created because C and other procedure-oriented languages
could not address the complex problems that are present in real life. So the question of translating C++ code to C is absurd. You have to
rewrite the code completely and that would be no small feat.


Sorry, Karthik, but your history is not accurate.

C++ *is* a "procedure-oriented language", just with a more
flexible mechanism than for C to decide -which- procedure to use.

If you want a non-procedural language, you will have to look at
programming languages such as PROLOG that specify goals and
leave it up to the language implimenter on how to systematically
approach the goals. Do not confuse "object-oriented" with
non-procedural !!

C++ was not invented because C *could not* be used for certain
problems: C++ was invented because reformulating parts of C made
for a language that some problems easier to express, and made it
easier to write generalized toolkits to encourage software re-use.

The only part of C++ that is noticably difficult to express
in C is "exceptions" -- which were *not* the driving force of
C++ language development [unlike, say, Ada.]
Translating C++ to C is *not* "absurd". The first C++
compilers, designed by the author of C++ himself, was
'cfront', which translated the C++ code into C for
compilation by your nearest handy C compiler. 'cfront'
was managed and distributed by AT&T at the time, and
is still available from Lucent (the vehicle that
AT&T spun a fair bit of their technology off to.)
I found it on lucent's site just yesterday. I happened
to be using an old browser so I couldn't easily check
out the licensing conditions and pricing.
--
"I want to make sure [a user] can't get through ... an online
experience without hitting a Microsoft ad"
-- Steve Ballmer [Microsoft Chief Executive]
Nov 14 '05 #4

Gancy wrote:
Hi all,
Are there any version of g++ that translates C++ to C. or any open
source compiler to do this.

Thanks
Ganesh


On some modern C++ compilers there is an option to generate C code
(like in the cfront days)

Nov 14 '05 #5
In article <11**********************@l41g2000cwc.googlegroups .com>,
ka**********@gmail.com <ka**********@gmail.com> wrote:
Walter Roberson wrote:
In article <11*********************@l41g2000cwc.googlegroups. com>, The only part of C++ that is noticably difficult to express
in C is "exceptions" -- which were *not* the driving force of
C++ language development [unlike, say, Ada.]
What about constructors, virtual base classes, inheritance,
polymorphism etc?
My understanding is that virtual base classes and inheritance
become fixed at compile time -- one can climb the type hierarchy
to figure out what is what, since one has to define a class before
using it in a derived class. I could be wrong, as I have not used
C++ in a few years.

It's been a while since I read The Design And Evolution of C++,
but my -recollection- is that polymorphism came later. In any case,
one can have the overhead structure include a member which indicates
the type, and could if necessary include a pointer to a list of
types. The compiler could build up a type symbol table and then
save space by storing a type number rather than a type name. Or
you could make arrangements based upon pointers into the type tables
of subelements of class hierarchies. Whatever.

Translating C++ to C is *not* "absurd". The first C++
compilers, designed by the author of C++ himself, was
'cfront', which translated the C++ code into C for
compilation by your nearest handy C compiler.

So how would you translate a class definition and object construction
into C? Use structures and then malloc?
Sure.
Won't this be a huge task
indeed?
The code wasn't pretty, and it was somewhat verbose in order to
take all the conversions into account, but I'm told that
with a bit of practice one could debug it.
I would definitely be interested in learning more about this.
Can you provide some links that would help in understanding the concept
better?


http://www.lucenttls.com/displayProduct.cfm?prodid=56

http://www.cs.usfca.edu/~parrt/cours....overview.html
--
Look out, there are llamas!
Nov 14 '05 #6
Gancy wrote:
Hi all,
Are there any version of g++ that translates C++ to C. or any open
source compiler to do this.


It's not open-source, but Comeau C++ (http://www.comeaucomputing.com/)
works by translating C++ to a platform-specific version of C,
customised for the native C compiler on the system.

--
Simon.
Nov 14 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bengt Richter | last post by:
Just thought None as the first argument would be both handy and mnemonic, signifying no translation, but allowing easy expression of deleting characters, e.g., s = s.translate(None,...
1
by: shank | last post by:
I'm sure this is a stretch, but is there some kind of component that I could install to translate from English to Spanish on the fly? I have a lot of equipment features and specifications that I...
4
by: Gadrin77 | last post by:
I have data that looks like <Root> <Main Value="Line1|Line2.|Line3|Line4.|Line5"/> </Root> I'm using Translate(@Value, "|.", ",")
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
6
by: Anders K. Olsen | last post by:
Hello group I'm trying to list the users and groups who has read access to a file. I use .NET 2.0 and FileInfo.GetAccessControl().GetAccessRules(...) and then loop through the...
1
by: peterbe | last post by:
This has always worked fine for me. Peter fine Now if I do it with a unicode string: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/string.py", line...
9
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006...
1
by: =?Utf-8?B?R2F1cmF2?= | last post by:
Hi, I am using the Translate() function in one of the .XSLT file to remove the spaces, like this: <xsl:for-each select=".//Illustration"> <xsl:value-of select="translate(./@illusName, ' ',...
3
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
4
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.