Harald van Dijk wrote:
....
I was assuming the code would not be compiled from any of the standard
include locations. When it's not, <stdint.h> first searches the standard
include locations, never seeing the custom stdint.h. C90 implementations
without <stdint.h> would search the standard include locations first,
fail to find anything, and then behave as if #include "stdint.h" was used.
The behaviour is not meant to be undefined if a file named stdint.h is
placed in a location searched for #include "..." but not #include <...>,
is it? "Standard places" isn't completely clear, so I'm not entirely sure.
It's very deliberately vague; the standard says very little about these
issues. There's an implementation-defined list of locations which are
searched when you use #include <filename>, and a possibly, but not
necessarily, different implementation-defined list of locations that are
searched when you use #include "filename". About the only relevant thing
the standard says is that if the set of places searched by
#include "filename"
doesn't contain the named file, the search is repeated as
if #include <filename>
had been written.
If you use a compiler in a mode where it supports at least <stdint.h>
(even if it doesn't support any other C99 feature), you need to make
sure that no user-defined file of that name is in the list of standard
search locations. You'll need to read your implementation's
documentation to determine which places those are, and there's no
guarantee that they doesn't include the current directory or the
directory containing the source code file that has the #include line in
it. There's no guarantee about the order that they're searched in, and
there's no guarantee that later finds in the search order will be
ignored. In practice, the implementation itself often provides such
guarantees, but there's no such requirement in the standard.