Re: #include behavior (was: Automatically generate variables)



Beej Jorgensen <beej@xxxxxxx> writes:
In article <lntzxcabmx.fsf@xxxxxxxxxxxxxxx>,
Keith Thompson <kst-u@xxxxxxx> wrote:
7.1.2 paragraph 3:

If a file with the same name as one of the above < and > delimited
sequences, not provided as part of the implementation, is placed in
any of the standard places that are searched for included source
files, the behavior is undefined.

Interesting. That says that if I place a "stdlib.h" file in one of
the places searched for a
#include "stdlib.h"
directive but *not* for a
#include <stdlib.h>

Hmmm. That wasn't my read... Elaborate.

Why not for <stdlib.h>, especially since "" is a "superset" (so to
speak) of <>?
[...]

Sorry, the scope of the "*not*" was unclear.

Suppose the compiler searches for <foo.h> in /usr/include, and for
"foo.h" in $HOME/include and then /usr/include (these are just
arbitrary examples). 7.1.2p3, as I read it, says that if I place a
"stdlib.h" file in $HOME/include (which, as I wrote above, is one of
the places searched for "stdlib.h", but not one of the places searched
for <stdlib.h>), then the behavior is undefined.

If I place a "stdlib.h" file in /usr/include, of course, it also
causes UB.

And I just noticed that 7.1.2p3 talks about "a file with the same
name", which ignores the mapping specified by 6.10.2. In 6.10.2,
it says that <foo.h> refers to

a header identified uniquely by the specified sequence between the
< and > delimiters

whereas "foo.h" refers to

the source file identified by the specified sequence between the "
delimiter

What does "identified by" mean here? Is "foo.h" actually the *name*
of the file (as would be accepted by fopen(), or is it subject to the
same mapping as <foo.h>?

The implementation shall provide unique mappings for sequences
consisting of one or more letters or digits (as defined in 5.2.1)
followed by a period (.) and a single letter. The first character
shall be a letter. The implementation may ignore the distinctions
of alphabetical case and restrict the mapping to eight significant
characters before the period.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: A definition of two (2) please?
    ... Delimiters means separators, ... Godel mapping from sequences of numbers to individual numbers. ... responses how far down into the foundations I want to go. ...
    (sci.logic)
  • Re: Cohens paper on byte order
    ... A mapping is involved, and it plays a role in the ... specify (at least, ... hex notation to binary notation. ... > transcribing bit sequences to hexs and vice versa. ...
    (sci.crypt)
  • Re: #include behavior
    ... possibility to place a source file into some place. ... standard header names. ... which ignores the mapping specified by 6.10.2. ... case, for simplicity), then those two mappings map characters sequences ...
    (comp.lang.c)
  • Re: Cohens paper on byte order
    ... AES does define a mapping onto sequences of bits. ... > communication and storage; sequences of uint8s are. ...
    (sci.crypt)