Can CPP preprocessing statement in Fortran be indented?

穿精又带淫゛_ 提交于 2019-11-28 14:31:05

No, they cannot be indented because gfortran runs CPP in traditional mode which does not allow indentation. They must always start in the first column.

You could run CPP manually, but be very very careful about that. If you use the // string concatenation operator somewhere the preprocessor would treat it as a comment. You must use the -C flag as shown by @ewcz in his/her answer which disables discarding of comments.

Some compilers supply their own FPP preprocessor which behaves differently.

ewcz

you could use the C preprocessor to do the processing and then compile the processed file, i.e., assuming that your program is in main.f90, then something like:

cpp -nostdinc -C -P -w main.f90 > _main.f90
gfortran -o main _main.f90

In this connection, this question is quite useful: Indenting #defines

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