While trying to rebuild some ancient Fortran code using gfortran 10.2.0, I get the following from an include that contains a preprocessor #define:
$ gfortran preproc.f
minimal.inc:1:2:
1 | #define UD_POINTER integer*8
| 1
Warning: Illegal preprocessor directive
minimal.inc:2:7:
2 | UD_POINTER utmake
| 1
Error: Unclassifiable statement at (1)
The minimal source file preproc.f looks like this:
program preproc
include 'minimal.inc'
end program
...and minimal.inc is:
#define UD_POINTER integer*8
UD_POINTER utmake
The "Unclassifiable statement" error is obviously a consequence of the "Illegal preprocessor directive" warning. If I simply copy the 'include' contents into the source file it works fine, but this is not a suitable solution because I want to maintain separation of code between the application and the library where the include is from.
Adding -cpp
does not change anything. Changing gcc/gfortran versions to as far back as 4.8.5 does not fix it. I haven't found a compiler flag that touches it. What's going on here? What can I do to get it to comprehend that #define
?