Which gfortran compiler flag is associated with the warning “Illegal preprocessor directive”?

喜夏-厌秋 提交于 2019-12-11 02:53:54

问题


When using pFUnit (3.2.9) to test my Fortran code, I get many "Illegal preprocessor directive" warnings, e.g.

Warning: Illegal preprocessor directive
/path/to/my/file/test.f90:37:2:

 #line 26 "/path/to/my/file/test.f90"
  1

The code compiles and runs fine, so I would like to turn off these warnings, while still seeing other compiler warnings. Which gfortran compiler flag turns this specific warning off? I am working with gfortran 7.3.1.


回答1:


This is not the kind of warning that one should turn off because not using a preprocessor has usually very bad consequences on codes that use the most common directives like #define and #if. And as far as I know it isn't possible to turn it off.

It is much wiser to enable the preprocessor using the -cpp flag. Not only the warnings will stop but you will get the correct line numbers in further diagnostics as well, the line numbers will refer to your original code.



来源:https://stackoverflow.com/questions/50477689/which-gfortran-compiler-flag-is-associated-with-the-warning-illegal-preprocesso

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!