Updated gcc compiler file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Updated gcc compiler file

David Harrison-13
Problem: When using the gcc "compiler" setting under Linux and you
need to find warnings or errors  in the quicklist via the vimscript
getqflist()....... THERE ARE NONE!

Note: It seems that the errorformat string for gcc doesn't specify
flagging either Warnings or Errors for the quickfixlist. You only get
a list of strings output by gcc.  While they are in fact either
warnings or errors, Vim only sees them as raw messages.

Solution: Add the appropriate lines into the gcc "compiler" setting to
flag warnings/errors.

Here is my proposed fix (can it be included into Vim 7.3?):

" Vim compiler file
" Compiler:         GNU C Compiler
" Maintainer:       Nikolai Weibull <[hidden email]>
" Latest Revision:  2010-5-20

if exists("current_compiler")
  finish
endif
let current_compiler = "gcc"

let s:cpo_save = &cpo
set cpo-=C

CompilerSet errorformat=
      \%*[^\"]\"%f\"%*\\D%l:\ %m,
      \\"%f\"%*\\D%l:\ %m,
      \%-G%f:%l:\ %trror:\ (Each\ undeclared\ identifier\ is\
reported\ only\ once,
      \%-G%f:%l:\ %trror:\ for\ each\ function\ it\ appears\ in.),
      \%f:%l:\ %tarning:\ %m,
      \%f:%l:\ %trror:\ %m,
      \%f:%l:\ %m,
      \\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m,
      \%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',
      \%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',
      \%D%*\\a:\ Entering\ directory\ `%f',
      \%X%*\\a:\ Leaving\ directory\ `%f',
      \%DMaking\ %*\\a\ in\ %f

if exists('g:compiler_gcc_ignore_unmatched_lines')
  CompilerSet errorformat+=%-G%.%#
endif

let &cpo = s:cpo_save
unlet s:cpo_save

This will now allow getqflist() to flag warnings/errors.

--David

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Updated gcc compiler file

David Harrison-13
I made Vim place signs after doing a ":make" command (ends up looking
a bit like Eclipse or Visual Studio) by parsing the list returned by
getqflist(), but I soon discovered that Vim didn't know there were any
warnings or errors to look for.  While the getqflist() function
returned a list, the "type" of entry in a qflist was nonexistent.

To see an example of this, type ":make" and when it finishes, type
":echo getqflist()".  If you look for "'type' : " you'll see that it
has nothing associated with it.

So, I added the two lines that you indicated to the gcc "compiler"
file to resolve the issue.  Now, after I do a ":make", I have
correctly placed signs throughout the editor (looking for type = "w"
or "e").  As a bonus, any errors coming from ":make" are now
highlighted in the ErrMsg highlight group, which I wasn't expecting.
I'm referring to the use of ":cw" here and it's displayed window.

I figured the change wouldn't hurt anything since most people
(including myself until recently) just look at the output of ":make"
and probably don't use Vim scripts for automating that process.

Let me know if the change seems useful!

On Thu, May 27, 2010 at 2:45 PM, Nikolai Weibull <[hidden email]> wrote:

> On Thu, May 27, 2010 at 15:32, David Harrison
> <[hidden email]> wrote:
>
>> Solution: Add the appropriate lines into the gcc "compiler" setting to
>> flag warnings/errors.
>
> What gain does this provide, exactly?  (To everyone who worries that
> I’m in some way against this: I’m not against this, I just want to
> know.)
>
>> Here is my proposed fix (can it be included into Vim 7.3?):
>
> Please send a patch.  I assume that it’s only the addition of
>
>     \%f:%l:\ %tarning:\ %m,
>     \%f:%l:\ %trror:\ %m,
>
> that’s necessary, correct?
>

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php