Re: Automatically generate variables



Beej Jorgensen <beej@xxxxxxx> writes:
In article <qt5st2p2qdkctb7kmq554qdkj7dq6501f8@xxxxxxx>,
Mark McIntyre <markmcintyre@xxxxxxxxxxx> wrote:
If stdlib.h were included, you would know it was a C programme, since
stdlib.h is a standard header.

Or *would* you?

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>
directive, then the behavior is undefined. I suspect that wasn't the
intent. In the absence of 7.1.2p3, such a file wouldn't cause any
problems, because the compiler wouldn't see it. It also implies that
the behavior becomes undefined whether the program attempts to include
the header or not.

Note that, for some implementations, there may be no such places, the
search paths for <foo.h> and "foo.h" might be identical.

I also note that, by creating and installing such a file, I can
magically make my implementation 100% conforming (though not usefully
so); it makes all behavior undefined, so anything the compiler does is
conforming. But the implementation can't take advantage of this
trick, because the file is "not provided as part of the
implementation".

--
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: Machine epsilon: conclusion
    ... standard header *and* contain QFLT_EPSILON at the same time. ... The compiler you use has a file called ... He's not complaining about the behavior of your compiler. ... The suggestion that such extensions should be in separate headers is ...
    (comp.lang.c)
  • Re: Standard header and using
    ... It makes the iostream facilities (which has to do with ... if the standard header iostream defines the names cout then why in ... the compiler has to know what it is before it can be used. ... namespace is completely separate. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Happy New Year!
    ... >> Yes, a standard header is allowed to include other headers, but is not ... So, for a program to be truly compliant, all the headers ... Any other conforming implementation might not have ... of <ostream> which makes 'std::endl' hence defined. ...
    (comp.lang.cpp)
  • Re: .h for standard headers
    ... >> entry in a ToDo list. ... > Did that era include, say, 1999? ... Adding .h to the standard header files ... change/upgrade your compiler and/or the standard library implementation. ...
    (comp.lang.cpp)
  • Re: Headers/Libraries default locations
    ... There is no guarantee that there are "standard header files". ... In any case, *THE* compiler installs where ... There is no guarantee that there are "standard library files". ...
    (comp.lang.c)