Path: utzoo!utgpu!water!watmath!jagardner From: jagardner@watmath.waterloo.edu (Jim Gardner) Newsgroups: comp.lang.c Subject: Multiple includes of standard headers Message-ID: <19602@watmath.waterloo.edu> Date: 23 Jun 88 17:06:39 GMT References: <361@teletron.UUCP> <8074@brl-smoke.ARPA> Reply-To: jagardner@watmath.waterloo.edu (Jim Gardner) Organization: U. of Waterloo, Ontario Lines: 29 In article <8131@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn) writes: > So, for example, our header "Dx.h" uses the name >"Dx_HDR_INCLUDED" for its one-time lockout flag. [...] > >>This type of thing sure would be handy in the Unix header files (hint, hint). > >A start had already been made at doing this, and it is essential for >ANSI C conformance. (The C implementation will have to use macro >names starting with underscore for its lockout flags.) But can you lock out a standard header file? Section 4.1.2 says "...; each may be included more than once in a given scope, with no effect different from being included once, except that the effect of includingdepends on the definition of NDEBUG." If the effect of the first inclusion is to define a macro, say, putc(), then the effect of the second must be no different so it also must define putc(). E.g., #include #undef putc #include f() { putc(c,f); } At f(), putc should be a macro again. I don't really like this behaviour (I prefer having the locking out technique available), but the wording and the exception with seem to indicate that you cannot lock out the standard headers. Even if my interpretation is wrong (I hope it is!), I think the wording should be changed to make it clear to a non-lawyer.