If I have a -Idirectory in my compile path then #include "file.h" works but #include <file.h> does not. The compiler complains the file does not exist. I use the binaries from http://quatramaran.ens.fr/~coudert/gfortran/ and this broke between the snapshot in May and August. It seems to correspond to the switch to internal cpp.
I forgot to include version info: Using built-in specs. Target: i386-apple-darwin8.10.1 Configured with: /tmp/gfortran-20081006/ibin/../gcc/configure --prefix=/usr/local/gfortran --enable-languages=c,fortran --with-gmp=/tmp/gfortran-20081006/gfortran_libs --enable-bootstrap Thread model: posix gcc version 4.4.0 20081006 (experimental) [trunk revision 140904] (GCC)
Is there a problem with using the standard conforming INCLUDE statement? You forgot to include a small test case.
Confirm. gcc (the C compiler) has using -I test_directory: #include "..." search starts here: #include <...> search starts here: test_directory /usr/local/include /projects/tob/gcc-trunk/include /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include-fixed /usr/include End of search list. whereas gfortran has the following: #include "..." search starts here: test_directory /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/finclude . #include <...> search starts here: /usr/local/include /projects/tob/gcc-trunk/include /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include-fixed /usr/include End of search list.
Bugger. How much time do we have left before 4.4?
(In reply to comment #3) > #include "..." search starts here: > test_directory > /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/finclude > . That "." comes last is also wrong; it should come first for "...". However, CPP automatically takes care. Draft patch below; it works, except that I get the warning (-v -I tes): ignoring duplicate directory "tes" <<<<<<<<<<<<<<< Warning #include "..." search starts here: #include <...> search starts here: tes /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/finclude /usr/local/include /projects/tob/gcc-trunk/include /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include /projects/tob/gcc-trunk/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include-fixed /usr/include End of search list. Index: cpp.c =================================================================== --- cpp.c (Revision 141104) +++ cpp.c (Arbeitskopie) @@ -628,10 +628,9 @@ gfc_cpp_add_include_path (char *path, bo { /* CHAIN sets cpp_dir->sysp which differs from 0 if PATH is a system include path. Fortran does not define any system include paths. */ - int chain = 0; int cxx_aware = 0; - add_path (path, chain, cxx_aware, user_supplied); + add_path (path, BRACKET, cxx_aware, user_supplied); } void Index: options.c =================================================================== --- options.c (Revision 141104) +++ options.c (Arbeitskopie) @@ -266,8 +266,6 @@ gfc_post_options (const char **pfilename source_path[i] = 0; gfc_add_include_path (source_path, true); } - else - gfc_add_include_path (".", true); if (canon_source_file != gfc_source_file) gfc_free (CONST_CAST (char *, canon_source_file));
Sorry, for leaving out the test case, but I see it is confirmed now. I can't use the conforming INCLUDE since I am dealing with a large legacy code base and ~150 colleagues who are also using the code with various compilers etc.
Patch does not work - the "." causes problems as a "include" (not "#include") does not work anymore: The "." is not included. Still there is the issue about the order "." should be searched before the "-I" paths and it is not needed to be added for "#include" but only for "include". The latter can be solved by calling in this case in "gfc_add_include_path" only "add_path_to_list (&include_dirs" and not "gfc_cpp_add_include_path" but I fear that also the order for include_dirs has to be changed as well as OPT_I / -I<dir> come before the filename processing in gfc_post_options.
Subject: Bug 37821 Author: burnus Date: Mon Nov 3 07:20:24 2008 New Revision: 141544 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141544 Log: 2008-11-03 Tobias Burnus <burnus@net-b.de> PR fortran/37821 * cpp.c (gfc_cpp_add_include_path): Use BRACKET. * scanner.c (add_path_to_list): Argument to add at head. (gfc_add_include_path): Add new argument. (gfc_add_intrinsic_modules_path) Update call. (load_file): Print filename/line in the error message. * gfortran.h (gfc_add_include_path): Update prototype. * options.c (gfc_post_options,gfc_handle_module_path_options, gfc_handle_option): Update call. * lang-spec.h (F951_OPTIONS): Don't insert include path twice. * arith.c (arith_error): Add -fno-range-error to the message. 2008-11-03 Tobias Burnus <burnus@net-b.de> PR fortran/37821 * gfortran.dg/include_4.f90: New. * gfortran.dg/include_5.f90: New. * gfortran.dg/include_4.inc: New. Added: trunk/gcc/testsuite/gfortran.dg/include_4.f90 trunk/gcc/testsuite/gfortran.dg/include_4.inc trunk/gcc/testsuite/gfortran.dg/include_5.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/arith.c trunk/gcc/fortran/cpp.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/lang-specs.h trunk/gcc/fortran/options.c trunk/gcc/fortran/scanner.c trunk/gcc/testsuite/ChangeLog
FIXED on the trunk. Thanks for the report and sorry that it took that long to commit the fix.