cpp include bug

Zack Weinberg zack@wolery.cumb.org
Sat May 27 19:55:00 GMT 2000


On Fri, May 26, 2000 at 10:14:47PM -0700, Dan Nicolaescu wrote:
...
> It looks like the preprocessor thinks that it should not preprocess
> "endian.h" after it has seen #include <endian.h> 

Yep.  This looked like a simple bug at first, but turns out to be
nasty on deeper inspection.

To determine if a header file has already been seen, we look it up in
a hash table by its "short name" - which is endian.h in both cases.
The table entry has a pointer to the location in the search path where
it was found.  If that location is reachable by walking along the path
for this #include, the header is considered already-seen.  There are
then additional checks for whether it is to be scanned again.

The include path for your example looks something like this:

  "" starts here:
  .
  <> starts here:
  /usr/include

<endian.h> is found in /usr/include.  "endian.h" _could_ be found in
/usr/include, so we assume it's the same header - but neglect to
consider the possibility that there's a header in . which was never
examined.

There is no simple fix with the current data structure.  I'm going to
redesign it.  Unfortunately that means a patch won't be immediately
forthcoming.

zw





More information about the Gcc-bugs mailing list