home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: assert
- Message-ID: <1992Dec22.163928.10225@taumet.com>
- Organization: TauMetric Corporation
- References: <HBF.92Dec19163113@gandalf.uio.no> <1992Dec21.163006.8068@taumet.com> <9212211543.PN29748@LL.MIT.EDU>
- Date: Tue, 22 Dec 1992 16:39:28 GMT
- Lines: 49
-
- lebrun@ll.mit.edu (Steven F. LeBrun) writes:
-
-
- >> The first alternative (#include <stdio.h>) is forbidden by the C
- >> Standard (standard headers may not #include other standard headers).
- > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
- >I took a look at the ANSI C document (X3.159-1989) and could not find a
- >section that states that standard header files cannot include other
- >standard header files. As a matter of fact, section 4.11.2 "Standard
- >Headers" states that header files included in any order and may be
- >included more than once with the same effect as if they were included
- >only once. [There is an exception pointed out in this section about
- >the <assert.h> header file.]
-
- Taking the last first, a *program* may include the standard headers
- in any order and any number of times. This is not a license for
- the *implementation* to do so.
-
- There is no one sentence in the Standard which says that the standard
- headers may not include one another, but it is an unescapeable
- conclusion of ANSI section 4.1.2.1 (ISO 7.1.2.1), "Reserved Identifiers".
-
- Let's take a simple example to see why. If I do not include <stdarg.h>
- in my program, the identifier va_start is not reserved, and I may use
- it in any way that I like. The following complete program is strictly
- conforming:
-
- #include <stdlib.h> /* to get EXIT_SUCCESS */
- #include <stdio.h> /* to get printf */
- int main()
- {
- int va_start = EXIT_SUCCESS;
- printf("Hello\n");
- return va_start;
- }
-
- A naive implementation might include <stdarg.h> in <stdio.h> so that
- it would be easier to declare the v*printf functions. That would
- render this strictly-conforming program undefined. Therefore, such an
- implementation does not conform to the Standard. Similar examples exist
- for all the standard headers.
-
- Instead, implementations must jump through a few hoops to get everything
- done properly. You can read about this in more detail in the book
- "The Standard C Library" by P. J. Plauger, Prentice-Hall.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-