ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: Tasmania, Australia..the best place in the world..clean air & clean water..purely subjective of course!!!
Distribution: Red Hat 8.0
Posts: 20
Rep:
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
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.
Location: Tasmania, Australia..the best place in the world..clean air & clean water..purely subjective of course!!!
Distribution: Red Hat 8.0
Posts: 20
Original Poster
Rep:
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
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/ >.
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.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
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.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.