RFC: INCLUDE, #include and preprocessing

Tobias Burnus burnus@net-b.de
Fri Aug 15 12:07:00 GMT 2008


Steve Kargl wrote:
> On Thu, Aug 14, 2008 at 11:55:41PM +0200, FX wrote:
>   
>>> Tobias B. summarizes current compiler behaviour (PR37032, comment #7) as:
>>>    gfortran/netlib's fpp/NAG f95/openf95/sunf95/ifort: no
>>>    g95:   yes
>>>       
>> My own opinion is that preprocessing Fortran-include'd files is itself
>> a bug, and we are correct not to do that. We should document it. We
>> could, however, keep an enhancement PR about adding a compiler flag to
>> force preprocessing of Fortran-include'd files.
>>     
I concur; I think PR37032 can be kept open as enhancement PR for a flag.

Frankly, I also do not see any reason why one cannot use "#include" if 
one wants to have preprocessing - one just needs to add a "#" and it 
works with all CPP-aware compilers or with a separate preprocessing with 
any other CPP.

 * * *

Another but related issue is the search path (cf. PR 35707). For 
#include gfortran/cpp also search in /usr/include while for INCLUDE 
gfortran does not (while NAG f95, ifort and g95 also search /usr/include 
for INCLUDE). [Implementation issue: While for CPP the system-include 
path is known, for gfortran it is not. If one loads through CPP one 
automatically searches such directories. g95 "solves" this by statically 
including "/usr/include". On my system, the system-include path also 
consists of /usr/local/include, $GCC/$TARGET/include{,-fixed}.]

(The PRs about more advanced CPP features (which currently fail due to 
-traditional-cpp) have there validity as there is no simple fix as for 
"include" vs. "#include"; see e.g. PR 28662.)

Tobias



More information about the Fortran mailing list