为 -Wimplicit-interface 禁用 -Werror

Disabling -Werror for -Wimplicit-interface

在 GCC 中禁用将特定警告视为错误的正确标志或标志顺序是什么?我想为 -Wimplicit-interface.

这样做
>cat test.f90 
 call s
end

> gfortran -c -Werror -Wimplicit-interface -Wno-error=implicit-interface test.f90 -o test.o
test.f90:1.7:

 call s
       1
Warning: Procedure 's' called with an implicit interface at (1)

>ls test*
test.f90

没有生成 test.o

没有 -Werror 它有效

> gfortran -c -Wimplicit-interface -Wno-error=implicit-interface test.f90 -o test.o
test.f90:1.7:

 call s
       1
Warning: Procedure 's' called with an implicit interface at (1)
> ls test*
test.f90  test.o

GCC 版本为 gcc version 4.9.2 20141030 (Cray Inc.) (GCC)

这不是问题的明确答案。我觉得它很有教育意义,但太长了,无法作为评论。

正如您刚刚发现的,如果将 -Werror-Wno-error=implicit-interface 结合使用,您可能无法实现您想要的效果。让我解释一下:与我们在 doc 中所拥有的相反,尤其是下面的句子,

The combined effect of positive and negative forms is that more specific options have priority over less specific ones, independently of their position in the command-line.

实际执行起来好像不是这样。我最近遇到了类似的问题,通过谷歌搜索,我发现 this 包含这句话:

'-w' permanently sets all warnings off no matter what specific warning is set on

它实际上暗示通过使用一些非特定选项,实际实现不允许您更改非特定选项中包含的特定选项。

正如@innoSPG 所指出的,实际行为与手册中声称的不符。

@MarkGlisse 的评论显示这在 GCC 5 中有所改变。因此这可能是一个错误。

因此,解决方案是使用最新版本,或者不使用 -Werror-Wimplicit-interface 之一。

或者真正在任何地方都提供显式接口,但这可能会有问题,因为 MPI 库在 mpi 模块中提供的显式接口数量不同。