gpt4 book ai didi

vim - 使用 Vim :make with quickfix ends up creating a new file when error is in header

转载 作者:行者123 更新时间:2023-12-04 08:29:02 24 4
gpt4 key购买 nike

我使用 Vim 进行了设置,我可以在其中使用 :make 编译我的 C/C++ 代码,并且编译错误会使用我的 ./vimrc 中的以下行 (from the Vim wiki) 自动显示在快速修复窗口中:

" Automatically open, but do not go to (if there are errors) the quickfix /
" location list window, or close it when is has become empty.
"
" Note: Must allow nesting of autocmds to enable any customizations for quickfix
" buffers.
" Note: Normally, :cwindow jumps to the quickfix window if the command opens it
" (but not if it's already open). However, as part of the autocmd, this doesn't
" seem to happen.
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow

现在,如果 .cpp 文件 中存在 错误,则此设置运行良好,因为正确解析了 make 的输出:
$ make
g++ -c -o IsingMain.o IsingMain.cpp
g++ -c -o LatticeModel.o LatticeModel.cpp
LatticeModel.cpp: In member function ‘void LatticeModel::initialiseSystem()’:
LatticeModel.cpp:18:25: error: ‘sirand’ was not declared in this scope

即 vim 正确切换到 LatticeModel.cpp

但是,如果错误在 头文件 中,则 make 输出会被误解,并且 vim 会切换/创建一个名为“make ”的新缓冲区(对于以下示例 In file included from IsingMain.cpp 输出),显然错误地假设这是带有错误(实际上错误在 LatticeModel.h 中):
$ make
g++ -c -o IsingMain.o IsingMain.cpp
In file included from IsingMain.cpp:2:0:
LatticeModel.h:31:5: error: ‘Zvoid’ does not name a type

从命令行运行 make 效果很好,这只是 quickfix 误读了它的输出的问题。非常感谢任何帮助,让我知道这是否有任何部分令人困惑。谢谢

编辑 :这似乎与错误格式有关(如 this thread 中所述。)

编辑 2 :通过使用 this technique 忽略以“In file contains from”开头的 make 输出行找到的临时修复。

最佳答案

虽然我还没有找到合适的解决方案,但这里建议的解决方法是:http://groups.google.com/group/vim_dev/msg/ed4f258f5b4b9749
似乎暂时有效。

set errorformat^=%-GIn\ file\ included\ %.%# 

编辑 :另见 Vim tries to jump to nonexistent file after :make

关于vim - 使用 Vim :make with quickfix ends up creating a new file when error is in header,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6747337/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com