PATCH: cpp include directory search order warning

Neil Booth neil@daikokuya.co.uk
Wed Aug 7 13:28:00 GMT 2002


John David Anglin wrote:-

> On the otherhand, the above prevents a user from changing a system
> directory to a non-system directory, and reordering the default
> search of system directories with -I.  Maybe not a bad idea given
> the pitfalls.

Is there any good reason why a user might want to make a system directory
be a non-system directory?  If not, then I think Zack's suggestion is
a good plan.

Slightly off-topic:

The only thing I don't like is the listing under -v.  It's always seemed
a bit out of place, and bugged me a bit.  Why does -v display the
directory list anyway?  Do tools in the wild send -v and parse the
output to get this info?

What I'd like to do is get rid of the listing under -v, and implement
something like that suggested in PR preprocessor/4917.  I quote:

"This is an enhancement request to make the -print-search-dirs option
show the #include directory search list.

Currently, the output of gcc -print-search-dirs contains three lines:
    install: ...
    programs: ...
    libraries: ...

This proposal is to add a new line
    sysinclude: ... 
which would contain a :-separated list of directories searched by
#include <...> 

This would be useful for curious humans as well as automated scripts
to generate a tags database."

I believe -print-search-dirs is a driver option.  Sadly, the driver
does not have access to CPP's include list, so it cannot print this
stuff at present.  Further, the driver exits immediately after
dumping the info, making it awkward to pass the flag on to cc1,
particularly as it is effectively language-specific in this case.
However, I think we should do something like this.

I'm not sure what to do about CPP's default compiled-in include path.
We need it for fix-header, which links against cpplib, so I think cpplib
needs to be aware of it (rather than moving the logic into cc1 or even
the driver).  However, cpplib shouldn't be doing command-line switch
parsing, and so -I etc. should be moved to cc1 or to gcc.  cpplib should
export some interface where you pass it a list of paths, and something
equivalent to -nostdinc, and it merges those with its compiled-in default.

Neil.



More information about the Gcc-patches mailing list