使警告静音:fortran 中的“不合格制表符”
Silence the warning: `Non-conforming tab character` in gfortran
我通常使用 运行 我的代码 ifort
,但在实现过程中,我更喜欢使用 gfortran
进行编译和测试,因为我发现它比它的英特尔对应物要严格得多。
在打开 -Wall
等编译选项时,我收到以下警告:
Warning: Nonconforming tab character at (1)
有没有办法在使用相同的编译选项时消除这个特定的警告?请注意,我 NOT 想用 space 个字符替换制表符。如果没有办法解决这个问题,那么答案"No it's not possible"就足够了。
警告:我最初写的以下答案仅适用于 gfortran 4.x。该行为已在版本 5.x 中逆转,请参阅 。
到目前为止你尝试了什么? -Wtabs
有帮助吗?来自 man gfortran
:
-Wtabs
By default, tabs are accepted as whitespace, but tabs are not members of the Fortran Character Set. For continuation lines, a tab followed by a digit between 1 and 9 is supported. -Wno-tabs
will cause a warning to be issued if a tab is encountered. Note, -Wno-tabs is active for -pedantic, -std=f95, -std=f2003, -std=f2008 and -Wall.
并且-Wall
设置-Wno-tabs
。
如果没有帮助,可能仍然是 -Wall
覆盖了这个选项。然后你可以尝试手动设置 -Wall
没有标签部分:
-Wall
Enables commonly used warning options pertaining to usage that we recommend avoiding and that we believe are easy to avoid. This currently includes -Waliasing, -Wampersand, -Wconversion,
-Wsurprising, -Wc-binding-type, -Wintrinsics-std, -Wno-tabs, -Wintrinsic-shadow, -Wline-truncation, -Wtarget-lifetime, -Wreal-q-constant and -Wunused.
更新:对于 GCC/gFortran 5xx(我注意到 5.3.0),-Wtabs 的用法是 "reversed",正如他们所说,"made more sensible"。
看这里 (https://gcc.gnu.org/gcc-5/changes.html)
现在 -Wtabs 确实会发出不合格警告,而 -Wno-tabs 会关闭警告(即与之前的用法相反)。
在 gfortran 版本 4.x 中消除警告的最简单方法是覆盖 -Wall 标志设置的 -Wno-tabs 标志。所以首先包括 -Wall 然后 -Wtabs
-Wall -Wtabs
我通常使用 运行 我的代码 ifort
,但在实现过程中,我更喜欢使用 gfortran
进行编译和测试,因为我发现它比它的英特尔对应物要严格得多。
在打开 -Wall
等编译选项时,我收到以下警告:
Warning: Nonconforming tab character at (1)
有没有办法在使用相同的编译选项时消除这个特定的警告?请注意,我 NOT 想用 space 个字符替换制表符。如果没有办法解决这个问题,那么答案"No it's not possible"就足够了。
警告:我最初写的以下答案仅适用于 gfortran 4.x。该行为已在版本 5.x 中逆转,请参阅
到目前为止你尝试了什么? -Wtabs
有帮助吗?来自 man gfortran
:
-Wtabs
By default, tabs are accepted as whitespace, but tabs are not members of the Fortran Character Set. For continuation lines, a tab followed by a digit between 1 and 9 is supported. -Wno-tabs will cause a warning to be issued if a tab is encountered. Note, -Wno-tabs is active for -pedantic, -std=f95, -std=f2003, -std=f2008 and -Wall.
并且-Wall
设置-Wno-tabs
。
如果没有帮助,可能仍然是 -Wall
覆盖了这个选项。然后你可以尝试手动设置 -Wall
没有标签部分:
-Wall
Enables commonly used warning options pertaining to usage that we recommend avoiding and that we believe are easy to avoid. This currently includes -Waliasing, -Wampersand, -Wconversion, -Wsurprising, -Wc-binding-type, -Wintrinsics-std, -Wno-tabs, -Wintrinsic-shadow, -Wline-truncation, -Wtarget-lifetime, -Wreal-q-constant and -Wunused.
更新:对于 GCC/gFortran 5xx(我注意到 5.3.0),-Wtabs 的用法是 "reversed",正如他们所说,"made more sensible"。
看这里 (https://gcc.gnu.org/gcc-5/changes.html)
现在 -Wtabs 确实会发出不合格警告,而 -Wno-tabs 会关闭警告(即与之前的用法相反)。
在 gfortran 版本 4.x 中消除警告的最简单方法是覆盖 -Wall 标志设置的 -Wno-tabs 标志。所以首先包括 -Wall 然后 -Wtabs
-Wall -Wtabs