Using the #line directive with gfortran
marco restelli
mrestelli@gmail.com
Tue May 23 13:44:00 GMT 2017
Hi all,
I am confused by the treatment of the #line directive by gfortran.
Suppose that I have two files:
file_a.xyz:
program test
implicit none
integer :: i
<some lines consumed by a preprocessor>
<some lines consumed by a preprocessor>
<some lines consumed by a preprocessor>
<some lines consumed by a preprocessor>
j = 3
end program
! comments
! other comments
! ...
! more comments
file_b.F90
program test
implicit none
integer :: i
#line 8 "file_a.xyz"
j = 3
end program
! comments
! other comments
! ...
! more comments
The idea is that file_b.F90 comes from a preprocessing of file_a.xyz,
so all the compiler diagnostics should be referred to file_a.xyz.
Compiling file_b.F90 I see
$ gfortran -c file_b.F90 -o file_b.o
file_b.F90:8:2:
! other comments
1
Error: Symbol ‘j’ at (1) has no IMPLICIT type
So it seems that only the line number "8" is used by gfortran, but not
the file name: both the file name and the source line in fact are
referring to file_b.F90. I would like a message like
$ gfortran -c file_b.F90 -o file_b.o
file_a.xyz:8:2:
j = 3
1
Error: Symbol ‘j’ at (1) has no IMPLICIT type
(By the way, gcc on C code behaves like I would expect, showing the
name and the source line of the original file file_a.xyz.)
Is there a way to have this output from gfortran?
Thank,
Marco
More information about the Fortran
mailing list