Gcc Error Messages Format
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Is there any way to get readable gcc error and warning output at the command line? up vote 20 down vote favorite 7 For some long errors, the gcc output is dense and has lots of line-wrapping etc. Especially when errors are subtle, it can take me 10-30 seconds of squinting to parse it with my eyes. I've taken to pasting this in an open code-editor window to get some basic syntax highlighting and enable reformatting with regex's. Has anyone invented a more automated method? c++ c gcc gcc-warning share|improve this question asked Mar 17 '09 at 23:27 mikeh 1 I just make the window very wide... –i_am_jorf Mar 17 '09 at 23:33 And the font very small ;) –Anonymous Mar 17 '09 at 23:35 1 and then stop using gcc. :D –Robert P Mar 17 '09 at 23:44 2 Clarification: I love intel's c++ compiler. The messages are clean, short, and pointed. Back when I still had a license, I'd test my compiles in intel's compiler before I built with GCC just to find the big problems. –Robert P Mar 17 '09 at 23:45 @Robert I'm intrigued, hope I get a chance to try that sometime. Not appropriate on the current project unfortunately... –mikeh Mar 18 '09 at 4:28 | show 1 more comment 8 Answers 8 active oldest votes up vote 14 down vote I've found colorgcc to be invaluable. By introducing coloring, it becomes much easier to mentally parse the text of gcc error messages, especially when templates are involved. share|improv
messages is called "brief format." Brief format messages are written to `stderr' (the standard error file) and have the following form: e.adb:3:04: Incorrect spelling of keyword "function" e.adb:4:20: ";" should be "is" The first integer after the file name is the line number in the file, and the second integer is the column number within the line. glide can parse the error messages and point to the referenced character. The following switches provide control over the error message format: -gnatv The v stands for verbose. The effect of this setting is to write long-format error messages to `stdout' (the standard output file. The same program http://stackoverflow.com/questions/656420/is-there-any-way-to-get-readable-gcc-error-and-warning-output-at-the-command-lin compiled with the `-gnatv' switch would generate: 3. funcion X (Q : Integer) | >>> Incorrect spelling of keyword "function" 4. return Integer; | >>> ";" should be "is" The vertical bar indicates the location of the error, and the `>>>' prefix can be used to search for error messages. When this switch is used the only source lines output are those with errors. -gnatl The l stands for list. This switch causes a full http://www.delorie.com/gnu/docs/gcc/gnat_ug_41.html listing of the file to be generated. The output might look as follows: 1. procedure E is 2. V : Integer; 3. funcion X (Q : Integer) | >>> Incorrect spelling of keyword "function" 4. return Integer; | >>> ";" should be "is" 5. begin 6. return Q + Q; 7. end; 8. begin 9. V := X + X; 10.end E; When you specify the `-gnatv' or `-gnatl' switches and standard output is redirected, a brief summary is written to `stderr' (standard error) giving the number of error messages and warning messages generated. -gnatU This switch forces all error messages to be preceded by the unique string "error:". This means that error messages take a few more characters in space, but allows easy searching for and identification of error messages. -gnatb The b stands for brief. This switch causes GNAT to generate the brief format error messages to `stderr' (the standard error file) as well as the verbose format message or full listing (which as usual is written to `stdout' (the standard output file). -gnatm^^=^n The m stands for maximum. n is a decimal integer in the range of 1 to 999 and limits the number of error messages to be generated. For example, using `-gnatm2' might yield e.adb:3:04: Incorrect spelling of keyword "function" e.adb:5:35: missing ".." fatal error: maximum errors reached compilation abandoned
"here I am" post here to differ human beings from SPAM bots. Home Help Search Login Register Wiki Code::Blocks » User forums » General (but http://forums.codeblocks.org/index.php?topic=17834.0 related to Code::Blocks) » How to change the gcc build error messages http://www.avrfreaks.net/forum/visual-studio-and-gcc-error-format format in codeblocks? « previous next » Send this topic Print Pages: [1] Go Down Author Topic: How to change the gcc build error messages format in codeblocks? (Read 4658 times) Master Multiple posting newcomer Posts: 53 How to change the gcc build error messages format in codeblocks? « on: April gcc error 20, 2013, 12:34:13 pm » Hello every one,The subject is vague i know it , i couldn't just convey the meaning any better so i explain what i mean .according to http://gcc.gnu.org/wiki/ClangDiagnosticsComparison#fnref-c80f7dfc6950973199cc4f44ec4ae68de8e7cf2d : gcc now has a better Diagnostics , looking at the examples provided such as :Code: [Select]void foo(char **p, char **q)
{
(p - q)();
p();
}and trying to get gcc error messages the same thing in CB just fails , look at the error provided at gcc comparison page : Code: [Select]t.c:3:10: error: called object is not a function or function pointer
(p - q)();
^
t.c:4:4: error: called object ‘p' is not a function or function pointer
p();
^
t.c:1:17: note: declared here
void foo(char **p, char **q)
^and look at the error log generated inside CB : Code: [Select]C:\Users\Master\Documents\CodeBlocks\Test\main.cpp||In function 'void foo(char**, char**)':|
C:\Users\Master\Documents\CodeBlocks\Test\main.cpp|14|error: expression cannot be used as a function|
C:\Users\Master\Documents\CodeBlocks\Test\main.cpp|15|error: 'p' cannot be used as a function|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 11 seconds) ===|
I am using the gcc 4.8, How can i achieve the same behavior in CB? is there any kind of settings i am missing here? « Last Edit: April 20, 2013, 12:37:07 pm by Master » Logged a man's dream is an index to his greatness... jens Administrator Lives here! Posts: 7062 Re: How to change the gcc build error messages format in codeblocks? « Reply #1 on: April 20, 2013,
CommunitiesAVR FreaksAtmel SMART ARM-based MCUsInternet of ThingsCapacitive TouchProjectsVendorsWiki You are hereHome » Communities » AVR Freaks » Forums » Tools » Compilers and General Programming » Visual Studio and GCC error format Main menu mobile Home Communities Forums Projects Vendors Wiki Search My summary Privacy Contact Site Use Terms Cookies Communities Forums Projects Vendors WIKI Visual Studio and GCC error format Log in or register to post comments Go To Last Post 15 posts / 0 new Author Message kml013 Level: New Member Joined: Mon. Jul 28, 2008 Posts: 7 View posts #1 Posted by kml013: Mon. Jul 28, 2008 - 02:50 PM Fivestar widget 12345Total votes: 0 The problem i am facing is that the output format of errors list in GCC isn't the one Visual Studio accepts. The result is that you can't have your cursor positioned in the error's line by a simple click in the output window. Although i found some info in : http://lists.gnu.org/archive/html/avr-gcc-list/2005-06/msg00115.html It doesn't work for me. It produces errors. Anyone out there using VS with AVR-GCC and facing the same problem? Is there any workaround? Thanks for the replies. Tags:Tools, Compilers and General Programming Log in / register to post comments Top clawson Level: Moderator Joined: Mon. Jul 18, 2005 Posts: 83554 View posts Location: (using avr-gcc in) Finchingfield, Essex, England #2 Posted by clawson: Mon. Jul 28, 2008 - 02:54 PM 12345Total votes: 0 Some reason not to use AVR Studio? - it knows how to read GCC's error output. Log in or register to post comments Top kml013 Level: New Member Joined: Mon. Jul 28, 2008 Posts: 7 View posts #3 Posted by kml013: Mon. Jul 28, 2008 - 03:00 PM 12345Total votes: 0 For advanced editor features such as autocomplete, indent and others... After a trial period in eclipse and code::blocks. I found that vs fits more in my needs. Codeblocks comes next and i will prefer it in its next edition with a redisigned autocomplete mechanism. If AVR studio adds these features of course i will switch back in it :) But i have large projects with many variables, structures and functions to deal with. So i make my life easier with a more advanced IDE-editor. Any idea for my problem? Thanks Log in or register to post comments Top clawson Level: Moderator Joined: Mon. Jul 18, 2005 Posts: 83554 View posts Location: (using avr-gcc in) Finchingfield, Essex, England #4 Posted by clawson: Mon. Jul 28, 2008 - 03:03 PM 12345Total votes: 0 I kind of know what you mean. I use Source Insight myself and it can be trained to parse compiler output for errors using it's regular expressio