Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
  • 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.
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.


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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Loops Section Overview
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

576 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