gfortran编译器的Vim错误格式



我使用vim :make使用gfortran编译FORTRAN代码。我喜欢快速修复窗口在编译错误之间跳转的功能。我在这里使用gfortran建议的错误格式,它是:

errorformat=%E%f:%l.%c:,%E%f:%l:,%C,%C%p%*[0123456789^],%ZError: %m,%C%.%#

它检测到大部分错误。我想增加处理以下的可能性

  • 警告
  • 链接器错误
  • (奖金)涉及两个位置的错误:(1)和(2)

我已经阅读了文档,一段时间前,当我试图为英特尔FORTRAN制作一个错误格式时。这花了我很多时间,只是为了得到大概的结果。我想添加警告"%W"应该不会太困难,因为它具有相同的错误消息结构。对于链接器错误,我不知道它是否会起作用,因为我对源和对象使用不同的文件夹,并使用vpath Makefile功能。

下面我附上了一些gfortran编译器的错误消息示例,我希望通过errorformat来处理这些错误消息。

非常感谢您的帮助

错误示例(到目前为止由错误格式处理)

folder/file.f90:22.19:
        ini=.false.
         1
Error: Symbol 'ini' at (1) has no IMPLICIT type

警告示例

folder/file.f90:485.12:
        use SomeMod, only: somevar
            1
Warning: Unused module variable 'somevar' which has been explicitly imported at (1)

链接器错误示例

 /tmp/ccPcF56y.o: In function `MAIN__':
test.f90:(.text+0x8e0): undefined reference to `init_'
../../_build/amod.o: In function `__amod_MOD_dostuff':
amod.f90:(.text+0x3e32): undefined reference to `dothis_'
amod.f90:(.text+0x3e74): undefined reference to `dothat_'
collect2: error: ld returned 1 exit status

多个错误位置示例

file.f90:8.8:
    use AMod
        1
file.f90:231.25:
    call init()
         2
Error: 'init' at (1) has a type, which is not consistent with the CALL at (2)

这在某种程度上适用于

set efm=%A%f:%l.%c:,%C,%C %.%#,%ZError: %m,%ZWarning: %m,%f:(%.%#):%m
  • 多行部件(%A-%Z)平等地处理错误和警告
  • %C代码将跳过空行和以空白开头的行
  • 链接错误格式不会将您带到调用缺少函数的行,但它会打开正确的文件
  • 我不知道如何使用vim-errorformat处理多个错误的情况

这就产生了vim

:clist
 1 folder/file.f90:22 col 19:  Symbol 'ini' at (1) has no IMPLICIT type
 2 folder/file.f90:485 col 12:  Unused module variable 'somevar' which has been explicitly imported at (1)
 4 test.f90: undefined reference to `init_'
 6 amod.f90: undefined reference to `dothis_'
 7 amod.f90: undefined reference to `dothat_'

这就是我所做的,它有点工作,但不是很好的

set efm=%I%.%#In function%m,%I%.%#undefined reference to%m,%E%f:%l.%c:,%E%f:%l:,%C,%C%p%*[0123456789^],%ZError: %m,%ZWarning: %m,%C%.%#

最新更新