问题
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
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/3870330/ifort-suppress-unused-variable-warning-leave-all-others-intact