Ifort 抑制未使用的变量警告,保持所有其他不变

发布于 2024-09-26 10:49:04 字数 203 浏览 0 评论 0原文

我使用 ifort 和 gfortran 来编译我的 Fortran 程序。

不过,我也使用同事的来源,他有很多未使用的变量。 我怎样才能抑制这些编译,因为它们并不是真正的错误?

但是我不想在编译器选项中禁用 -pedantic-stan ,因此想要所有其他警告。

干杯并感谢您的帮助

i use ifort and gfortran to compile my Fortran program.

However i also use a coworkers source and he has got a lot of unused variables.
How can i suppress these for the compile, seeing as they are not really an error?

However i dont want to disable -pedantic and -stan in the compiler options and thus want all the other warnings.

cheers and thanks for the help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你是年少的欢喜 2024-10-03 10:49:04

使用 ifort 尝试 -warn [no]unused

而且,当我在这里时,我建议您删除未使用的变量。编译器可能不会将它们视为错误,但严格的软件工程将所有死代码和未使用的代码视为错误的;它增加了维护负担。

With ifort try -warn [no]unused.

And, while I'm here, I suggest you remove unused variables. The compiler may not regard them as an error, but disciplined software engineering regards all dead and unused code as erroneous; it imposes a maintenance burden.

北城半夏 2024-10-03 10:49:04

是的,正如高性能马克指出的那样,摆脱这些警告的最佳方法是告诉你的同事修复他的代码。

至于简单的解决方案,使用 gfortran,请查看 gcc 手册中的 -Wunused-### 选项:警告选项。值得注意的是,-Wno-unused-variable可能会做你想要的事情。

[...] 当你有 Intel Fortran 时,为什么还要使用 gfortran?

开发时,通过多个编译器运行代码有助于查找错误并生成可移植代码。

Yes, as High Performance Mark pointed out, the best way to get rid of those warnings is to tell your coworker to fix his code.

As for easy solutions, with gfortran, have a look at the -Wunused-### options in gcc's manual: Warning Options. Notably, -Wno-unused-variable might do what you want.

[...] why the heck would you use gfortran when you have Intel Fortran ?

When developing, running your code through multiple compilers helps in finding bugs and producing portable code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文