I am fairly new to use Fortran preprocessing statement and have a question which is probably pretty native. Can Fortran preprocessing statement be indented? I tested using Gfortran 4.8.1 on Linux (openSUSE Leap) and it turned out I it can not be indented at all.
The following code main.f90 works with gfortran -cpp main.f90 -o main
:
program main
implicit none
#ifdef DEBUG
print *, "I am in debug mode"
#endif
print *, "hello world!"
end program main
But the following throws an error:
program main
implicit none
#ifdef DEBUG
print *, "I am in debug mode"
#endif
print *, "hello world!"
end program main
The error message is Error: Invalid character in name at (1)
.
Does this mean that we should always write the preprocessing statement from the first beginning of the line or it is just a compiler specific rule? Any help would be greatly appreciated and thanks in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…