Ignore attempt to #include directory

Vladimir Prus vladimir@codesourcery.com
Sat Jun 9 17:35:00 GMT 2007


On Saturday 09 June 2007 20:41, Tom Tromey wrote:
> >>>>> "Vladimir" == Vladimir Prus <vladimir@codesourcery.com> writes:
> 
> Vladimir> The attached patch, approved off-list by Mark Mitchell and checked
> Vladimir> in to mainline, fixes this problem.
> 
> BTW, this was PR 11242.

Ah, ok.

> Vladimir> +      /* On most UNIX systems, open succeeds on a directory.  Above,
> Vladimir> +         we check if we have opened a directory and if so, set errno
> Vladimir> +         to ENOENT.  However, on Windows, opening a directory
> Vladimir> +         fails with EACCESS.  We want to return ENOENT in that
> Vladimir> +         case too.  */
> Vladimir> +      if (stat (file->path, &file->st) == 0
> Vladimir> +          && S_ISDIR (file->st.st_mode))
> Vladimir> +        errno = ENOENT;
> 
> This changes errno if stat fails.  I suppose this is a "shouldn't
> happen" condition.

Indeed, the errno can change. I'm not sure this is big problem in practice --
the error from opening a file is likely to be as good as error from stat for
purposes of reporting the problem to the user.

- Volodya



More information about the Gcc-patches mailing list