EASY Question!

Posted on 2003-03-11
Medium Priority
Last Modified: 2012-05-04
I just want to know what the flag is that you would put with g++ to create the C representation of the C++ program??

g++ first changes the C++ program to a C program and runs gcc on it, so how can I stop it and display the C file?
Question by:Intern
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Expert Comment

ID: 8116426
>>>g++ first changes the C++ program to a C program and runs gcc on it,

whereever u found this information . didnt they mention how to do this?

did u try looking at g++ manual .. all its capabilities are very well documented in its man page

Expert Comment

ID: 8116437
The C and C++ compilers are integrated; g++ is a script to
call gcc with options to  recognize  C++.   gcc  processes
input  files  through  one or more of four stages: prepro-
cessing, compilation, assembly,  and  linking.  

this never said that it converts the code to c..
so as far as i see...it calls gcc to recognize c++ code .. but  i doubt if it ever tries to convert to c..

Author Comment

ID: 8128196
Well if that is the case, my professor had no idea what he was talking about then.  He told me that g++ translated a C++ program to C then ran gcc on the C program.  

I thought a translator would make life easier, but I guess I will just start writing in C.  Maybe I will get good at that too.
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.


Author Comment

ID: 8129614
Linux does turn C and C++ code into assembly, then it runs an assembler on that code right?

because you can get the assembly listing with -S

Accepted Solution

akshayxx earned 80 total points
ID: 8132844
yes u can get the assembly listing.. and with -E u can get the preprocessed listing ..

but i am not sure that if u dont specify the -S option then  also it will try to make the assembly code ..
 may be it can generate object code directly from C code ..
but i have strong feeling that it does make the assembly code first .. always

and about your professor .. well he may be right .. why not u ask him for the  details . i wud luve to have new knowledge
.. but i believe there is no such intermediate step..

Expert Comment

ID: 8149109
in some discussion i came across this comment from some other expert .. might be of some interest to you..

In the long long time ago ...
C++ compiler always convert *.CPP to *.C, before compile it to machine code.
You can't believe it now, but yes it did. It convert the object into struct, the method into modified function, etc.

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question