Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim tries to jump to nonexistent file after :make

Tags:

vim

gcc

makefile

I'm using :make from vim and ending up jumping to the file with issues.

Recently, at least I noticed with gcc 4.6.1, vim jumps to incorrect file/line because it goes to the first reported line which has "In file included from ABC.h|5| 0," and there is no file called "In file included from ABC.h".

There is a solution to extract just the file name from the above line, ABC.h in this case, but that does not solve the problem as the problematic file is only included there.

Usually the next line indicates where the issue is and that's where I would like to jump:

MyDir/FGH.h|56 col 32| error: 'bad bad thing happened here'

Is there a known fix for this in vim?

like image 373
stefanB Avatar asked Feb 24 '12 07:02

stefanB


3 Answers

This a bug that is solved on new versions of Vim: Bug report logs - #62169.

You can use the following setting to solve the problem without upgrading Vim:

  set errorformat^=%-GIn\ file\ included\ from\ %f:%l:%c:,%-GIn\ file
           \\ included\ from\ %f:%l:%c\\,,%-GIn\ file\ included\ from\ %f
           \:%l:%c,%-GIn\ file\ included\ from\ %f:%l

(setting extracted from latest Vim source code, from file src/option.h)

like image 110
mMontu Avatar answered Dec 19 '22 06:12

mMontu


:make! doesn't jump to the first result.

like image 30
romainl Avatar answered Dec 19 '22 07:12

romainl


The problem is with slight differences in the errorformat required for recent versions of gcc.

I believe this was mentioned in C++ Lounge (chat) the other day, and an errorformat was posted that supposedly works better. I haven't tested that it does:

  • https://chat.stackoverflow.com/search?q=errorformat&room=10

     errorformat=%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GInfile included from %f:%l:%c:,%-GIn file included from %f:%l:%c\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%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,%f|%l| %m
    
like image 21
sehe Avatar answered Dec 19 '22 07:12

sehe