473,789 Members | 2,957 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A CFront-like compiler available?

Hi,
I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is very
pragmatical for a C programmer to learn Java more effectively.

Any one can give me some information on that ? Tools, compilers or
other methods applicable are all attractive to me. But where to get
them?

Thanks.
Mar 4 '07
16 2747
Bu*******@hotma il.com writes:
On Sun, 04 Mar 2007 22:32:33 +1300, Ian Collins <ia******@hotma il.com>
wrote:
>>Bu*******@hot mail.com wrote:
>>Hi,
I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is very
pragmatical for a C programmer to learn Java more effectively.
How can a tool that converts C++ to C help a C programmer to learn Java
more effectively?
Oh, what I wrote is not clear indeed. Well, what I mean is that I hope
to get a tool that can translate or compile Java/C++ code into C code,
just like the old CFront did. I think this would be meaningful and
helpful for me to dig into the deep implementation mechanism of C++ or
Java through reading C code.
<OT>
C++ and Java are two very different languages.
</OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 4 '07 #11
Bu*******@hotma il.com wrote:
On 4 Mar 2007 03:01:15 -0800, "santosh" <sa*********@gm ail.comwrote:
Bu*******@hotma il.com wrote:
<snip>
Yes, it is really a great job to understand every aspect of a big
language like C++ or Java, however, what I care the most is its
runtime characteristics instead of their compilers or even the whole
language systems. I use Assembly language to study C and thus have
achieved a very good undestanding of the C runtime mechanism. So, I
wonder if there is also a similar way to analyze C++ or Java. In my
opinion, that is really a short-cut.
<snip>
C is closer to assembler than C++ and particularly Java. You'll have
to know the innards of the compiler/VM and associated libraries, in
conjunction with the language's specification to really understand
what's happening at the machine level.

All this assuming that you can get a tool to translate arbitrary C++
and Java source into C.

What you said is very helpful to me and I am preparing to study more
about C++ compiler and Java VM, that seems to be a real need. Thank
you.
Unless you're fairly proficient in Java and C++, you'll have a very
difficult time understanding their implementations , even if they
happen to be in C. Ditto, for their runtime behaviour.

I wouldn't go about this way if I were you, but YMMV.

Mar 4 '07 #12
In article <7m************ *************** *****@4ax.com>,
<Bu*******@hotm ail.comwrote:
>I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is very
pragmatical for a C programmer to learn Java more effectively.
(Hmm, coulda sworn I just responded to this in another NG?)

Be careful with pragmatics. Also, be careful what you wish for :)
>Any one can give me some information on that ? Tools, compilers or
other methods applicable are all attractive to me. But where to get
them?
Comeau C++ (http://www.comeaucomputing.com ) does, at least as
an internal phase of translation does, so I'm not sure to what
extent that can be helpful.

You mention something about Java above, but it's unclear what
your intention are, so feel free to elaborate, as there may be
better approach to what you're trying to do that we can offer.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port 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?
Mar 4 '07 #13
In article <d5************ *************** *****@4ax.com>,
<Bu*******@hotm ail.comwrote:
>On Sun, 04 Mar 2007 22:32:33 +1300, Ian Collins <ia******@hotma il.com>
wrote:
>>How can a tool that converts C++ to C help a C programmer to learn Java
more effectively?

Oh, what I wrote is not clear indeed. Well, what I mean is that I hope
to get a tool that can translate or compile Java/C++ code into C code,
just like the old CFront did. I think this would be meaningful and
helpful for me to dig into the deep implementation mechanism of C++ or
Java through reading C code.
Comeau C++ can do what you seek but probably won't help you in this
case as our translation to C is normally an internal phase of
translation.

Also, unlike some of the others who posted here, I can see merit
in donning a hazmat suite and jumping right in, however,
I agree with them this as a first tier approach to understanding,
this is barking up the wrong tree.

Not mentioned in this is to pick up a copy of Lippman's Inside
The C++ Object Model (see http://www.comeaucomputing.com/booklist
for more info on it) which pretty much covers a cfront perspecive
to the model. Very insightful, but again, not necessarily necessary
for understanding C++ or Java, if I'm understanding you correctly.
You should be considering high level concept for that.

You also seem to be seeking some sort of C++ <--Java relationship,
and it may or may not be there.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port 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?
Mar 4 '07 #14
In article <48************ *************** *****@4ax.com>,
<Bu*******@hotm ail.comwrote:
>On 4 Mar 2007 02:15:52 -0800, "santosh" <sa*********@gm ail.comwrote:
>>Bunny....@hot mail.com wrote:
>>On 4 Mar 2007 02:03:21 -0800, "santosh" <sa*********@gm ail.comwrote:
Bu*******@hot mail.com wrote:
I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is very
pragmatical for a C programmer to learn Java more effectively.

Any one can give me some information on that ? Tools, compilers or
other methods applicable are all attractive to me. But where to get
them?

Why do you want to do this, particularly for learning Java.

PS. I don't think any extant tool does what you want.

Oh, what I wrote is not clear indeed. Well, what I mean is that I hope
to get a tool that can translate or compile Java/C++ code into C code,
just like the old CFront did. I think this would be meaningful and
helpful for me to dig into the deep implementation mechanism of C++ or
Java through reading C code.

Hmm, I think you're off on a wild goose chase. If you want to
understand how C++ and Java programs are compiled and how their
runtime support is implemented, you'll have to understand their
standards, the source code of a conforming implementation and it's
accompanyin g libraries, not to mention the characteristics of the
target machine architecture.

Simply reading a source translation will get you nowhere, even if you
can find a tool to do that.

Yes, it is really a great job to understand every aspect of a big
language like C++ or Java,
If that is true, and I'll buy it to some extents, one problem with your
approach is that you will be limiting yourself to one perspective,
in the meantime, implementations have fairly good liberty to do as they
choose on many things. So looking at what you're seeking will not be
the complete picture, though certainly part of it.
>however, what I care the most is its
runtime characteristics instead of their compilers or even the whole
language systems.
What do you mean by "runtime charactertics"? And which "facts" in
particular are you trying to seek?
>I use Assembly language to study C and thus have
achieved a very good undestanding of the C runtime mechanism. So, I
wonder if there is also a similar way to analyze C++ or Java. In my
opinion, that is really a short-cut.
It's one appaoach, but it's painfully low level and can be a distorted
focus. I'm not saying people shouldn't some of this, or that it can't
be handy in some cases to know, but I'm still unclear on the problem
you're trying to solve? IMO, HLLs are for allowing us to more easily
model and express the problems we're trying to solve, and for that,
I'd rather very much first trying to understand that features and their
semantics and uses.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port 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?
Mar 4 '07 #15
In article <11************ **********@v33g 2000cwv.googleg roups.com>,
santosh <sa*********@gm ail.comwrote:
>It depends on what exactly you mean by runtime system. You can try to
understand what's happening at a machine level for compiled languages
by examining the assembly output of the language's compiler, but this
is far more difficult for interpreted languages like Java. Java in
I'll even up sanosh one. :) That is to say, it's still even hard
with the compiled languages. Because IMO when you say *a* machine level,
although there can be commonalities, you're really looking at one
machine at a time, and even worse, one version of one compiler for
one machine at a time. That's a lot of work. :) And probably
misleading (at least narrow) often.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port 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?
Mar 4 '07 #16
santosh wrote:
Bu*******@hotma il.com wrote:
>I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is
very pragmatical for a C programmer to learn Java more effectively.

Any one can give me some information on that ? Tools, compilers or
other methods applicable are all attractive to me. But where to get
them?

Why do you want to do this, particularly for learning Java.

PS. I don't think any extant tool does what you want.
I think Comeau does it for C++.

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt >
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/(C99)
<http://www.dinkumware. com/refxc.html (C-library}
<http://gcc.gnu.org/onlinedocs/ (GNU docs)
<http://clc-wiki.net (C-info)
Mar 4 '07 #17

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

Similar topics

18
2081
by: Bootstrap Bill | last post by:
Are there any open source C++ compilers that will produce C code? I understand the first C++ compilers operated this way.
133
8604
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
10
503
by: Rohit Upadhyay HCST | last post by:
Hi !!! I wanted to migrate to c++, But Im in no hurry so I actually want to see how the C++ calls get translated into C, using Cfront(the original thing that Bjourne developed). But I cant find any place to download it from ? Any links,resources ?
0
1572
by: Alfred B. Thordarson | last post by:
I have unsuccessfully searched back and forth for a solution to the following problem. I hope someone out there can help me. I have created a C++ .NET wrapper for a 3-rd party C based DLL (cfront.dll from Navision) but the wrapper access to the DLL doesn't work for some of the exported functions?!? To illustrate what I mean, I have created the following small test-case. You simply compile and link it using the cf.h and libload.c (from...
14
3289
by: Henning Hasemann | last post by:
Hi all, sounds trivial (I hope it is): Im searching for a way to get a time-value thats more exact than just seconds (i.e. I need milli- or microseconds or something similar, just at least as good as 1/100 second should suffice) and it should work with gcc (really g++) under linux and the MingW compliant under windows xp. I found an easy and universal sounding way in gmtime & co, but they dont seem to be available under my windows mingw...
2
2789
by: napi | last post by:
I managed to compile CFront 3.03 on my Ubuntu Linux kernel 2.6.20-15. I compiled CFront with g++ version 4.1.2 and used bison 2.3 to process the gram.y file. When I compiled this program using "CC -F hello.C": --------------------------------------- hello.C------------------------------------------------- struct y { int p;
5
1999
by: JohnQ | last post by:
What is the status of cfront in regards to copyright and licensing? The source code is available on the web in at least one location (should it be?). John
104
4624
by: JohnQ | last post by:
Well apparently not since one can step thru template code with a debugger. But if I was willing to make the concession on debugging, templates would be strictly a precompiler thing? I have a feeling the answer I'm going to get back will be "no, because templates have taken on a life of their own since their original conception and now also affect compiler implementation" (read: not good, IMO. John
40
2689
by: Campy Happer | last post by:
Hello all, I would like to bring to your attention a concept and a term for it that I think is long overdue. But first: In the bad old days of programming, before subroutines were even available, people used to write "spaghetti code", which was an unreadable, unmaintainable mess of "goto" statements.
7
1712
by: Chris | last post by:
Hi All, This is a weird one but I am hoping someone can help or has some pointers, a recipe how to do the following: I have to move some code from c++ to objective-c and to do this I must remove all defined templates. I am not really a c++ guy so I have not worked with templates all that much (not really at all) and as such I don't have a good idea where to start.
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7529
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.