Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GCC Option -S

Status
Not open for further replies.

LF28

Programmer
Nov 22, 2002
52
DE
Hi everybody,

is there a way to make gcc insert the c++ source lines into the .s file? I am somewhat confuded with the assembler listing generated from a .cpp file.

Like this:

gcc -S somefile.cpp

outputs to somefile.s which is the assembler code representation of somefile.cpp

Any ideas?

Greets, Tobi
 
It doesn't work if the .s file is optimized. For instance, you may code

for (int i = 0; i < 10; i++)
{
dosomething ();
}

It could code it as the equivalent of

i = 0;
xxx:
if (i >= 10) goto yyy
dosomething ();
i++;
goto xxx;
yyy:

or

i = 0;
goto xxx;
yyy:
dosomething
i++;
xxx:
if (i < 10) goto yyy;

The latter is the option used by most optimizing compilers as it is one conditional branch less and is actually faster even though it looks a bit strange. It would be quite difficult to fit the source code to that.
 
@xwb
thanx for the reply. I know it would be difficult but anyway I would like to have this feature ;). The MS Visual C++ compiler is capable of doing just that and I thought it would be cool to have this feature while using a linux system.
BTW MS C++ shows the C++ code lines regardless of the code being optimized or not... (at least it tries)

Tobi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top