LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   g++ compiler listings (https://www.linuxquestions.org/questions/programming-9/g-compiler-listings-50750/)

davmer 03-19-2003 07:28 PM

g++ compiler listings
 
now that i have started to compile i have a question re compiler listing output

I have searched this site trying to find how to get a compiler listing output from g++. further can i specify with options whether or not i choose to show user includes and/or system includes to prevent verbosity

I have used indirection to get my errors to a file ok with either &> filename.lst or 2> filename.lst
so for e.g
g++ test.cpp -o test 2> test.err

gave me my errors in a nice file which i can look at with cat but they were truncated so that i could not read the full text of the message

I have looked at all of the g++ options with man on my platform and no option seems to relate to compiler listings

wapcaplet 03-20-2003 09:48 PM

I take it you're saying that a message on a particular line is cut off? Maybe there is some limit to the size of lines that can be redirected.

Looking through the man page for your shell (csh, bash, etc.) might give you more info about this. I don't know of any compiler options to cut down on the length of error messages, but you might check out the g++ man page too.

Are the errors really cut off so much that you can't figure out how to fix the error? Most of the time, if you have a source file name, and a line number, you can figure out what the error is, and then you don't even need to read the whole message.

davmer 03-20-2003 11:10 PM

hi wapcaplet,

the options i am after are ones which produce a listing of the program post compile with the includes expanded, cross reference list,etc. On a platform (IBM AS400) that i work on at work we can even specify whether or not you get a print and if printing whether to expand system includes and/or user includes plus a whole lot of other things.

the output i get from the g++ compiler is truncated...i will try and give you an example of what i am getting...and no because of truncation i cannot interpret what the warning messages are saying to me as the sentences are incomplete

GtkUser 03-20-2003 11:36 PM

It's not truncated on my system. The Complete Reference GCC is a book with all kinds of information on gcc and g++. You can get this information online as well I think < http://gcc.gnu.org/ >.

Mik 03-21-2003 09:09 AM

Are you sure your terminal isn't set to truncate long lines? Try viewing the contents of the output file with vi. I don't think g++ is the one that is truncating the lines.

Randux 04-30-2006 05:06 AM

Sorry to revive an old thread, but I have the same question as the OP, and it didn't get answered.

For you guys who never programmed in the days when compilers produced listings this may sound strange. Judging from the confusion generated by this thread, everybody is familiar with error listings. But we want a source listing which is a listing generated by the compiler, showing the source code, with line numbers and other annotations, like offsets to names in structures, lengths of structures and their members, etc.

I have not been able to find any mention of this in the gcc doc at gcc.gnu.org.

If anyone understands what we are asking for and knows if it's possible/not possible with gcc, please update this thread.

Quote:

On a platform (IBM AS400) that i work on at work we can even specify whether or not you get a print and if printing whether to expand system includes and/or user includes plus a whole lot of other things.
This is exactly what I want, because I want to see includes expanded in a nicely formatted way.

Thanks,
Randux

randyding 04-30-2006 11:41 AM

The gcc -E option stops after preprocessing, and you get the result to stdout.

Randux 04-30-2006 01:24 PM

Hi Randy,

That's not really what I was looking for, but it is certainly better than what I had until now! Thanks for your update. I sent a question to the gcc list and if I get anything work repeating I will update this thread.

For anyone else reading this, Randy's suggestion causes gcc to write the source with the includes expanded. This helps if you want to see all your source and includes in one place.

randyding 04-30-2006 05:43 PM

Actually it does quite a bit more, it also shows all of the macro expansions. This option is most useful when trying to debug complex macro usages that don't seem to be compiling as expected.


All times are GMT -5. The time now is 04:12 PM.